in reply to Re^3: Generalising string in pattern
in thread Generalising string in pattern
update - typo fixuse strict; use Benchmark qw/cmpthese/; my $p = 'stringwithnospacesinit'; my ($a,$b); cmpthese( -5, { a => sub{ $a = $p; $a =~ s/(.)/$1\\s*/g; }, b => sub{ $b = $p; $b = join('\s*',split(//,$b)); }, } ); __END__ Rate a b a 62530/s -- -20% b 78403/s 25% --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Generalising string in pattern
by shmem (Chancellor) on Nov 13, 2009 at 15:31 UTC |