Thursday, September 2, 2010

I need a few lines of nasty Perl 5 code.

I am writing a talk for beginning Perl 5 programmers covering how to read a line of code and I need a few nasty lines that are fairly self contained. These should be normal lines of code (no obfuscation), they just need to have a lot going on in them. Things involving multiple maps with complex bodies would be good. If you have one or more such beasts, would you leave a comment with them?

The talk will be given at The Pittsburgh Perl Workshop.


  1. From Perl::Dist::WiX::BuildPerl::_get_cpan_upgrades_list (you can get a properly indented version there, the first few lines are context):

    my @modulelist = CPAN::Shell->expand('Module', '/./');

    # Schwartzian transform from
    my @expand;
    @expand = map {
    } sort {
    $b->[0] <=> $a->[0]
    $a->[1]{ID} cmp $b->[1]{ID},
    } map {
    } @modulelist;

  2. Web::Simple's Web::Simple::DispatchParser::_parse_spec has some good tricks like do{} blocks, hash slices, push-ors, and other niceties. It was created by mst for the "Antiquated Perl" talk, after all..


Some limited HTML markup is allowed by blogger: strong, b, i, and a. You may also use em, but I have repurposed it through the magic of CSS to be behave very much like <tt><code></code></tt>.