Cool/useful short examples of Perl?

Leo Lapworth leo at
Mon May 30 11:40:57 BST 2011


I'm working on and I'd like to have a few rotating
example of what can be done with Perl on the home page.

The first two I've thought of are below, does anyone have others?

They don't have to use CPAN modules, one liners are fine as long as it
is simple to see what they do. I'll have a 'more' link which goes on to
show full example with line by line explanations.

Module preference is anything from


This is probably max sort of size...

  # Send an email
  use Email::Sender::Simple qw(sendmail);
  use Email::Simple;
  use Email::Simple::Creator;

  my $email = Email::Simple->create(
    header => [
      To      => '"Xavier Q. Ample" <x.ample at>',
      From    => '"Bob Fishman" <orz at>',
      Subject => "don't forget to *enjoy the sauce*",
    body => "This message is short, but at least it's cheap.\n",



  # Serve static files from document root with a directory index
  # app.psgi
  use Plack::App::Directory;
  my $app = Plack::App::Directory->new({ root => "/path/to/htdocs" })->to_app;

  > plackup
  > Accepting connections at http://0:5000/

Thanks in advance!


More information about the mailing list