in reply to Splitting a string to chunks
Any way to make it faster ?
On my machine, this is slightly faster still:
'substr_loop2' => sub { my @arr; my $s = $str; push @arr, substr $s, 0, 8, '' while $s; },
More seriously, though, not all the subs in your OP are equivalent: 'substr_map' will truncate any string at a multiple of eight characters, while the others will include the extra characters in the final element of the array (Fengor's my @arr = $str =~ /(........)/g has the same problem).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Splitting a string to chunks
by Fengor (Pilgrim) on Nov 29, 2006 at 16:30 UTC | |
by johngg (Canon) on Nov 29, 2006 at 23:25 UTC |