Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    
    ...
    
    my $h = 'my $i = sub { print map {$_ *= 2; "$_ ";} @f; print "\n" }; $
    +i->();';
    eval ($h);
    
  2. or download this
    use strict;
    use warnings;
    use Benchmark;
    ...
        "idiomatic" => q[     $_ +=2 for @array2; ],
        "map"       => q[ map $_ +=2,    @array2; ],
    };
    
  3. or download this
    Benchmark: timing 50000 iterations of idiomatic, map...
     idiomatic:  3 wallclock secs ( 2.87 usr +  0.00 sys =  2.87 CPU) @ 17
    +421.60/s (
    n=50000)
    ...
    n=50000)
           map:  3 wallclock secs ( 3.04 usr +  0.00 sys =  3.04 CPU) @ 16
    +436.55/s (
    n=50000)