in reply to Still don't undersand "Modification of a read-only value attempted" error
The for-loop aliases the variable (here $item) to the list elements. If the list element is a literal, s/// cannot modify it.
On the other hand @list = ("abcdef", "ghijkl", "Dumbo"); puts the elements into an array, and you can always change array elements.
Or phrased differently, it's the same as
"abcdef" = 3; # doesn't work $list[0] = 3; # works
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Still don't undersand "Modification of a read-only value attempted" error
by choroba (Cardinal) on Jun 20, 2012 at 22:04 UTC | |
by Athanasius (Archbishop) on Jun 21, 2012 at 07:53 UTC |