Not only 'premature optimization is the root of all evil'; not only such a microoptimization is completely meaningless; but it's actually the other way around... declaring variables inside a loop is quite a bit faster.
Really? Go figure> (It's (much) more complicated than that!):
use strict; use warnings; use Benchmark qw( cmpthese ); my @strings = qw( USERID1|2215|Jones| USERID1|1000|Jones| USERID3|1495|Dole| USERID2|2500|Francis| USERID2|1500|Francis| ); cmpthese( -1, { outside => sub { my ( $x, $y, $z ); for (@strings) { ( $x, $y, $z ) = split /\|/; } }, outside2 => sub { my ( $x, $y, $z ); for (@strings) { ( $x, $y, $z ) = split /\|/, 3; } }, inside => sub { for (@strings) { my ( $x, $y, $z ) = split /\|/; } }, inside2 => sub { for (@strings) { my ( $x, $y, $z ) = split /\|/, 3; } }, } ); __END__ C:\test>junk Rate outside inside inside2 outside2 outside 58201/s -- -38% -71% -73% inside 93659/s 61% -- -53% -57% inside2 197610/s 240% 111% -- -10% outside2 218802/s 276% 134% 11% --
When you can explain that; then you may pontificate on the subject.
In reply to Re^4: Best way to store/sum multiple-field records?
by BrowserUk
in thread Best way to store/sum multiple-field records?
by bobdabuilda
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |