in reply to Array shuffle code produces 'Modification of non-creatable array value attempted' error
$ perl -e' @a = qw( abc def ); $a[-1] = "ghi"; $a[-2] = "jkl"; $a[-3] = "mno"; ' Modification of non-creatable array value attempted, subscript -3 at - +e line 4.
In your code, that will happen when an empty array is passed to shuffle. Fix by changing
towhile ( --$i )
while ( --$i > 0 )
|
|---|