It shouldn't really affect the efficiency much, as you're limitting the split to a maximum of two results returned, and so having a longer string passed to the split won't affect it. Either way, the difference in efficiency will be negligible
use Benchmark; use strict; timethese(1000000, { 'One Liner' => \&one_liner, 'Two Liner' => \&two_ +liner }); sub one_liner { # Stick all variables in the functions, so we can # see if there's any extra overhead for the extra # variable in two_liner. my $text = q/Here is some test text. I don't really know what I'm typing here, but does it really matter? I don't think so. I'm just kind of hitting random keys and stuff/; my $next_line; ($text, $next_line) = split /\n/, $text.$next_line, 2; } sub two_liner { my $text = q/Here is some test text. I don't really know what I'm typing here, but does it really matter? I don't think so. I'm just kind of hitting random keys and stuff/; my($next_line, $pre_next_line); ($text, $pre_next_line) = split /\n/, $text, 2; $next_line = $pre_next_line . $next_line; } Benchmark: timing 1000000 iterations of One Liner, Two Liner... One Liner: 21 wallclock secs (19.85 usr + 0.00 sys = 19.85 CPU) Two Liner: 22 wallclock secs (22.85 usr + 0.00 sys = 22.85 CPU)

In reply to RE: RE: Re: always in quest to eliminate temporary variables by plaid
in thread always in quest to eliminate temporary variables by visnu

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.