Cool/useful short examples of Perl?
Mark Fowler
mark at twoshortplanks.com
Tue May 31 15:06:19 BST 2011
Depends if you're looking semi-technical or not. How about my hostify
script that puts DNS entries into /etc/hosts?
http://blog.twoshortplanks.com/2011/01/30/hostify/
Mark.
On Mon, May 30, 2011 at 11:40 AM, Leo Lapworth <leo at cuckoo.org> wrote:
> Hi,
>
> I'm working on http://learn.perl.org/ 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 http://search.cpan.org/dist/Task-Kensho/
>
> E.g.:
>
> 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 example.com>',
> From => '"Bob Fishman" <orz at example.mil>',
> Subject => "don't forget to *enjoy the sauce*",
> ],
> body => "This message is short, but at least it's cheap.\n",
> );
>
> sendmail($email);
>
> or
>
> # 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!
>
> Leo
>
More information about the london.pm
mailing list