Actually, I like passing the arguments so that I can do things like this: (sum doesn't know to look at $a and $b)

use List::Util qw/sum/; say for map_pairs \&sum, 1..10;

I do like the aliasing bonus, but it seems to not work on hash keys:

use YAML; my @array = ( foo_name => " Bob Smiley ", foo_age => " 32" ); map_pairs { $a =~ s/foo_//; s/^\s+//, s/\s+$// for $b; } @array; print Dump \@array; my %hash = ( foo_name => " Bob Smiley ", foo_age => " 32" ); map_pairs { $a =~ s/foo_//; s/^\s+//, s/\s+$// for $b; } %hash; print Dump \%hash;

outputs

--- - name - Bob Smiley - age - 32 --- foo_age: 32 foo_name: Bob Smiley

Good Day,
    Dean


In reply to Re^3: Mini-Tutorial: Working with Odd/Even Elements by duelafn
in thread Mini-Tutorial: Working with Odd/Even Elements by ikegami

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":