rovf has asked for the wisdom of the Perl Monks concerning the following question:
I'm not asking for a solution this time (because I've solved the problem), but for an explanation - I would like to know why my solution worked. This was the original problem:
We had some code which basically looked like this:
Due to a mistake, $foo was set up in a way that the expression in the foreach produced a "Pseudo Hash Deprecated" error. I would have expected to see the output# This is file P.pm package P; use strict; use warnings; use PX; .... eval { PX::myfunc(...); }; if($@) { print "Exception!\n"; } .... # This is file PX.pm package PX; use strict; use warnings; sub myfunc { ... print("let's do it\n"); foreach my $c (@{ $foo->{bar}->{baz} }) { oink_oink_oink(); } print "I've done it\n"; }
but instead I was seeinglet's do it Exception!
and the program terminated. I solved this by changing PX.pm so that the warnings Pragma in PX.pm readslet's do it Pseudo hashes are deprecated at....
I saw the expected output. This puzzles me for two reason:use warnings FATAL => qw(all);
First, I understand that using a pseudo hash results in a run-time error, which means an exception should be generated. Since the calling program uses eval, the exception should have been caught here.
Second, the modified pragma just means that "warnings are turned into an exception". Since "Pseudo hashes are deprecated" is not a warning (after all, the program aborted afterwards), it should not be affected by warnings FATAL=>'all'. Could someone enlighten me here? This was run on ActiveState Perl 5.8.8.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: use warnings; and deprecated Pseudo hashes
by ambrus (Abbot) on Aug 27, 2009 at 13:35 UTC | |
|
Re: use warnings; and deprecated Pseudo hashes
by JavaFan (Canon) on Aug 27, 2009 at 13:36 UTC | |
by rovf (Priest) on Aug 27, 2009 at 13:42 UTC |