Using a simple Benchmark example:
$ perl -le' use Benchmark q/cmpthese/; my @data = map { join( "", map { ( "a" .. "z" )[ rand 26 ] } 1 .. 10 + + rand( 10 ) ) . "\n" } 1 .. 1_000; cmpthese -10, { plus => sub { my @temp = @data; s/\s+$// for @temp; return @temp; }, star => sub { my @temp = @data; s/\s*$// for @temp; return @temp; } } ' Rate star plus star 336/s -- -66% plus 992/s 196% -- $ perl -le' use Benchmark q/cmpthese/; my @data = map { join( "", map { ( "a" .. "z" )[ rand 26 ] } 1 .. 10 + + rand( 10 ) ) . "" } 1 .. 1_000; cmpthese -10, { plus => sub { my @temp = @data; s/\s+$// for @temp; return @temp; }, star => sub { my @temp = @data; s/\s*$// for @temp; return @temp; } } ' Rate star plus star 334/s -- -72% plus 1211/s 263% --
It appears that \s+ is always faster than \s*. YMMV
In reply to Re^4: Unsuccessful stat on file test
by jwkrahn
in thread Unsuccessful stat on file test
by bluethundr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |