Some benchmarks:
#!/usr/bin/perl use strict; use warnings; use Benchmark; my @test= qw(this that what where who how why); my $results = timethese(50000, { 'map' => sub { print map ("$_\n", @test) }, 'printfor' => sub { print "$_\n" for @test; }, 'join' => sub { print join("\n", @test),"\n"; }, 'forprint' => sub { for (@test) {print "$_\n"; } }, 'plain' => sub { print @test; }, #plain is for additional test like abigail 'abigail' => sub { $,=$\=$/; print @test; }, }, 'none' ); Benchmark::cmpthese($results);
My results:
Rate map printfor forprint abigail join plai +n map 48544/s -- -2% -5% -52% -71% -72 +% printfor 49505/s 2% -- -3% -51% -70% -71 +% forprint 51020/s 5% 3% -- -50% -69% -70 +% abigail 102041/s 110% 106% 100% -- -39% -41 +% join 166667/s 243% 237% 227% 63% -- -3 +% plain 172414/s 255% 248% 238% 69% 3% - +-

Update:
Ok, so I plugged Abigail's code in as well and I would of thought it would be the fastest. As the test 'plain' shows it is, when you aren't slowed down by an assignment.

Further update: Added a couple more tests and saw my problem.


In reply to Re: Beginning to see the light.... by lemming
in thread Beginning to see the light.... by earthboundmisfit

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.