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;
You have an off-by-one error. If you could do that, it should be
my @a; $a[ $_ ] = chop $buffer for length($buffer)-1 .. 0;
A simple fix for the already-described problem is to use negative indexing:
my @a; $a[ -$_ ] = chop $buffer for 1..length($buffer);
|
|---|