[Israel.pm] Selective warnings use
Gaal Yahas
gaal at forum2.org
Wed Feb 9 12:42:10 PST 2005
I wrote:
>You can pull a re-exec() trick. Off the top of my head, and obviously
>not tested:
>
> #!/usr/bin/perl
>
> BEGIN {
> if ($] < 5.006) {
> if (($ARGV[0]||"") ne "__hack__")) {
> exec $^X, $0, "__hack__", @ARGV;
> } else {
> eval "use warnings; 1" or die $@;
> }
> }
>
Beh, this can't happen in a BEGIN block -- it can't happen in a block at
all, for the warnings pragma scope to propagate!
This looks like one of the rare cases where the the semantics of a
statement modifier are significant (it does not introduce a scope).
# top level
eval "use warnings" if $need_to;
die $@ if $@;
Also I forgot to shift out the hack-argument in the case where we're in
the second invocation.
--
Gaal Yahas <gaal at forum2.org>
http://gaal.livejournal.com/
More information about the Perl
mailing list