summaryrefslogtreecommitdiff
path: root/pod/perlfunc.pod
diff options
context:
space:
mode:
authorDavid Nicol <davidnicol@gmail.com>2008-03-21 07:56:12 -0500
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2008-03-25 09:22:24 +0000
commit8a5a710d2a11ee78ddb137b0ff2b5ca547dc295d (patch)
tree5a93ec0c3878be61e289b96ce4597f82ece0a982 /pod/perlfunc.pod
parent502d9230ec570254fed51ae721c1da50944a5cbf (diff)
downloadperl-8a5a710d2a11ee78ddb137b0ff2b5ca547dc295d.tar.gz
Re: local $@ has an unwanted side effect
From: "David Nicol" <davidnicol@gmail.com> Message-ID: <934f64a20803211056q5148027ava77af36f51c96418@mail.gmail.com> (with Tim Bunce's amendments) p4raw-id: //depot/perl@33558
Diffstat (limited to 'pod/perlfunc.pod')
-rw-r--r--pod/perlfunc.pod16
1 files changed, 16 insertions, 0 deletions
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index e0b8049abf..886aae9b30 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -1625,6 +1625,22 @@ normally you I<would> like to use double quotes, except that in this
particular situation, you can just use symbolic references instead, as
in case 6.
+The assignment to C<$@> occurs before restoration of localised variables,
+which means a temporary is required if you want to mask some but not all
+errors:
+
+ # alter $@ on nefarious repugnancy only
+ {
+ my $e;
+ {
+ local $@; # protect existing $@
+ eval { test_repugnancy() };
+ # $@ =~ /nefarious/ and die $@; # DOES NOT WORK
+ $@ =~ /nefarious/ and $e = $@;
+ }
+ die $e if defined $e
+ }
+
C<eval BLOCK> does I<not> count as a loop, so the loop control statements
C<next>, C<last>, or C<redo> cannot be used to leave or restart the block.