summaryrefslogtreecommitdiff
path: root/pod/perltrap.pod
diff options
context:
space:
mode:
Diffstat (limited to 'pod/perltrap.pod')
-rw-r--r--pod/perltrap.pod27
1 files changed, 27 insertions, 0 deletions
diff --git a/pod/perltrap.pod b/pod/perltrap.pod
index 79e3ae5ca9..dd219c064b 100644
--- a/pod/perltrap.pod
+++ b/pod/perltrap.pod
@@ -324,6 +324,12 @@ Using local() actually gives a local value to a global
variable, which leaves you open to unforeseen side-effects
of dynamic scoping.
+=item *
+
+If you localize an exported variable in a module, its exported value will
+not change. The local name becomes an alias to a new value but the
+external name is still an alias for the original.
+
=back
=head2 Perl4 Traps
@@ -486,6 +492,27 @@ works fine, however.
=item *
+The meaning of foreach has changed slightly when it is iterating over a
+list which is not an array. This used to assign the list to a
+temporary array, but no longer does so (for efficiency). This means
+that you'll now be iterating over the actual values, not over copies of
+the values. Modifications to the loop variable can change the original
+values. To retain Perl 4 semantics you need to assign your list
+explicitly to a temporary array and then iterate over that. For
+example, you might need to change
+
+ foreach $var (grep /x/, @list) { ... }
+
+to
+
+ foreach $var (my @tmp = grep /x/, @list) { ... }
+
+Otherwise changing C<$var> will clobber the values of @list. (This most often
+happens when you use C<$_> for the loop variable, and call subroutines in
+the loop that don't properly localize C<$_>.)
+
+=item *
+
Some error messages will be different.
=item *