Interesting question, lets find out. I used Benchmark to figure this out. I ran them through at 50,000 iterations, and I changed all the "print" statements to "warn" statements, so I could pipe STDERR to /dev/null, and still see the results of the benchmark on STDOUT. Here's the code:
#!/usr/bin/perl -w use strict; use Benchmark; use vars qw/ @a @b /; @a = ('a'..'z'); timethese(50000, { '1' => '@b = map uc,@a; warn @b,"\n"', '2' => '@b = map uc $_,@a; warn @b,"\n"', '3' => '@b = map uc(),@a; warn @b,"\n"', '4' => '@b = map uc($_),@a; warn @b,"\n"', '5' => '@b = map {uc} @a; warn @b,"\n"', '6' => '@b = map {uc $_} @a; warn @b,"\n"', '7' => '@b = map {uc()} @a; warn @b,"\n"', '8' => '@b = map {uc($_)} @a; warn @b,"\n"', });
And here are the results:
Benchmark: timing 50000 iterations of 1, 2, 3, 4, 5, 6, 7, 8... 1: 4 wallclock secs ( 4.55 usr + 0.03 sys = 4.58 CPU) @ 10917.03/s +(n=50000) 2: 5 wallclock secs ( 4.51 usr + 0.03 sys = 4.54 CPU) @ 11013.22/s +(n=50000) 3: 5 wallclock secs ( 4.53 usr + 0.03 sys = 4.56 CPU) @ 10964.91/s +(n=50000) 4: 4 wallclock secs ( 4.54 usr + 0.03 sys = 4.57 CPU) @ 10940.92/s +(n=50000) 5: 5 wallclock secs ( 4.52 usr + 0.06 sys = 4.58 CPU) @ 10917.03/s +(n=50000) 6: 5 wallclock secs ( 4.52 usr + 0.00 sys = 4.52 CPU) @ 11061.95/s +(n=50000) 7: 4 wallclock secs ( 4.34 usr + 0.01 sys = 4.35 CPU) @ 11494.25/s +(n=50000) 8: 5 wallclock secs ( 4.31 usr + 0.04 sys = 4.35 CPU) @ 11494.25/s +(n=50000)
While these results show #7 and #8 as being the fastest, I would consider this inconclusive. The fact is, it's so close that every time I run this test, I keep getting wide ranging answers, even with 50,000 iterations.

Either way, it was still fun :-)
-Eric

Updated: Fixed a booboo pointed out by chipmunk. The benchmark actually runs correctly now :-)

In reply to Re: Tribute to TMTOWTDI by andreychek
in thread Tribute to TMTOWTDI by s0ttle

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.