diff options
author | Glenn Linderman <perl@nevcal.com> | 2006-10-30 04:50:21 -0800 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-11-08 11:23:13 +0000 |
commit | 746d7dd7d06cedb05d9bb8a5b7714677c4dba404 (patch) | |
tree | aeb30ce959294aadfb618a6770cf8bc36036fbe9 | |
parent | ac979cf5a6398fe3588f85b203caac3e0ac8b7ea (diff) | |
download | perl-746d7dd7d06cedb05d9bb8a5b7714677c4dba404.tar.gz |
Re: New version diagnostic breaks a bunch of modules.
Message-ID: <4546658D.6090507@NevCal.com>
p4raw-id: //depot/perl@29230
-rw-r--r-- | pod/perlfunc.pod | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 5ef30d7aea..db1980f57e 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -1288,13 +1288,17 @@ trapped within an eval(), $@ contains the reference. This behavior permits a more elaborate exception handling implementation using objects that maintain arbitrary state about the nature of the exception. Such a scheme is sometimes preferable to matching particular string values of $@ using -regular expressions. Here's an example: +regular expressions. Because $@ is a global variable, and eval() may be +used within object implementations, care must be taken that analyzing the +error object doesn't replace the reference in the global variable. The +easiest solution is to make a local copy of the reference before doing +other manipulations. Here's an example: use Scalar::Util 'blessed'; eval { ... ; die Some::Module::Exception->new( FOO => "bar" ) }; - if ($@) { - if (blessed($@) && $@->isa("Some::Module::Exception")) { + if (my $ev_err = $@) { + if (blessed($ev_err) && $ev_err->isa("Some::Module::Exception")) { # handle Some::Module::Exception } else { |