in reply to Re^2: RFC - FAQ for Modification of a read-only value attempted
in thread RFC - FAQ for Modification of a read-only value attempted

No. Example Re^3: RFC - FAQ for Modification of a read-only value attempted Also see perlsyn (RTFM is good for you):
If any element of LIST is an lvalue, you can modify it by modifying VAR inside the loop. Conversely, if any element of LIST is NOT an lvalue, any attempt to modify that element will fail. In other words, the "foreach" loop index variable is an implicit alias for each item in the list that you're looping over.
  • Comment on Re^3: RFC - FAQ for Modification of a read-only value attempted

Replies are listed 'Best First'.
Re^4: RFC - FAQ for Modification of a read-only value attempted
by imp (Priest) on Aug 29, 2006 at 14:16 UTC
    I have read perlsyn - foreach, and I do not feel your quotation is relevant for the example I provided. Perhaps you intended it for BrowserUk as his post dealt with the modification of the VAR lvalue.

    The relevant portion of the document for my example would be

    If any part of LIST is an array, foreach will get very confused if you add or remove elements within the loop body, for example with splice. So don't do that.
    I do not ever add or remove elements from LIST in actual code, but it serves as a possible example of iterating over an array - or perhaps an example of iterating over a lazily constructed list, as with for (1..99999999).