in reply to Re: Still don't undersand "Modification of a read-only value attempted" error
in thread Still don't undersand "Modification of a read-only value attempted" error

Also note that range operator behaves differently than a hardcoded list:
s/[u3]/X/, print for 1 .. 10, "a" .. "z"; # ok s/[u3]/X/, print for 1, 2, 3, 4, "a", "b", "u", "z"; # error again
  • Comment on Re^2: Still don't undersand "Modification of a read-only value attempted" error
  • Download Code

Replies are listed 'Best First'.
Re^3: Still don't understand "Modification of a read-only value attempted" error
by Athanasius (Archbishop) on Jun 21, 2012 at 07:53 UTC

    I find this interesting — and surprising! Range Operators in perlop has:

    Binary ".." is the range operator.... In list context, it returns a list of values .... If the left value is greater than the right value then it returns the empty list. ... In the current implementation, no temporary array is created when the range operator is used as the expression in foreach loops...

    This certainly makes it seem as though the range operator (in list context) returns an ordinary list, so why the difference in behaviour?

    Is this documented anywhere? Or is it an undocumented feature?

    Athanasius <°(((><contra mundum