in reply to Re^3: Convert string to array - performance challenge
in thread Convert string to array - performance challenge

 my @a; $a[ $_ ] = chop $buffer for length($buffer) .. 0;

Unfortunately, "reversed" ranges like length($buffer) .. 0  don't work...

print for 1..3; # 123 print for 3..1; # no output

However, this would work, and is actually pretty fast (about the same as substr):

my @a; for (my $i=length($buffer)-1; $i>=0; $i--) { $a[$i] = chop $buffer; } # or my @a; my $i = length($buffer); $a[--$i] = chop $buffer while $i>0;