>>>>> "JWK" == John W Krahn <jwkr...@shaw.ca> 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  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to