From: Paul David Fardy Date: Thu, 17 Aug 2000 17:23:40 +0000 (-0230) Subject: [ID 20000817.018] behaviour change 5.5.3 -> 5.6.0 re "Modification of a read-only... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c567402153be05de9e4e6ef0b23195e50431c6d8;p=p5sagit%2Fp5-mst-13.2.git [ID 20000817.018] behaviour change 5.5.3 -> 5.6.0 re "Modification of a read-only value" Message-Id: <200008171953.RAA17673@porthos.ucs.mun.ca> p4raw-id: //depot/perl@6696 --- diff --git a/pod/perldiag.pod b/pod/perldiag.pod index b55c7df..6f62e3c 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1865,6 +1865,14 @@ catches that. But an easy way to do the same thing is: Another way is to assign to a substr() that's off the end of the string. +Yet another way is to assign to a C loop I when I +is aliased to a constant in the look I: + + $x = 1; + foreach my $n ($x, 2) { + $n *= 2; # modifies the $x, but fails on attempt to modify the 2 + } + =item Modification of non-creatable array value attempted, %s (F) You tried to make an array value spring into existence, and the diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod index 6d820b6..e6b420e 100644 --- a/pod/perlsyn.pod +++ b/pod/perlsyn.pod @@ -309,9 +309,12 @@ The C keyword is actually a synonym for the C keyword, so you can use C for readability or C for brevity. (Or because the Bourne shell is more familiar to you than I, so writing C comes more naturally.) If VAR is omitted, C<$_> is set to each value. -If any element of LIST is an lvalue, you can modify it by modifying VAR -inside the loop. That's because the C loop index variable is -an implicit alias for each item in the list that you're looping over. + +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 C loop index variable is an implicit alias for each item +in the list that you're looping over. If any part of LIST is an array, C will get very confused if you add or remove elements within the loop body, for example with