>>>>> "JWK" == John W Krahn <[email protected]> writes:
JWK> Or as:
JWK> $_ = "$directory/$_" for @dirfiles[ 1 .. $#dirfiles ];
just to show another way that is usually faster for prepending a string:
substr( $_, 0, 0, "$directory/" ) for @dirfiles[ 1 .. $#dirfiles ];
that is called 4 arg substr and it is way underused in perl. this
benchmark shows the significant speedup of about 2x:
use Benchmark qw( cmpthese ) ;
cmpthese ( shift || -2, {
assign => sub { my $x = 'abc' ; $x = "qwerty/$x" },
substr => sub { my $x = 'abc' ; substr( $x, 0, 0, 'qwerty/') },
}
) ;
Rate assign substr
assign 2356409/s -- -47%
substr 4428292/s 88% --
--
Uri Guttman ------ [email protected] -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/