sincerely,
/iaw
use warnings FATAL => qw{ uninitialized };
-jp
Yes, but that would be rather strange since that particular warning is
probably the most common and reasonable one for which people
consciously wants to temporarily disable warnings.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
> use warnings FATAL => qw{ uninitialized };
Whoa! I was thinking about writing a die handler myself. I didn't know
about this semantic. Thank you!!
No problem. :-)
Another advantage of lexical warnings (people always ask...)
-jp
> On 24 Nov 2006 11:26:28 -0800, "DJ Stunks" <DJSt...@gmail.com> wrote:
>
>> use warnings FATAL => qw{ uninitialized };
>
> Whoa! I was thinking about writing a die handler myself. I didn't know
> about this semantic. Thank you!!
Kind of odd that it isn't mentioned in 'perldoc warnings', isn't it?
Granted, there's a cross-ref to 'perldoc perllexwarn' in there, but I'd
think it would worth at least a mention in 'perldoc warnings'.
Yah, I know - tell it to p5p, accompanied with a patch. Will do. :-)
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
That does not follow.
The fact that one often wants to treat undef as "" or 0 without warning
is in now way mutually exclusive with the idea that there are other
times when you'd want that same warning promoted to an error.
>> Yes, but that would be rather strange since that particular warning is
>> probably the most common and reasonable one for which people
>> consciously wants to temporarily disable warnings.
>
>That does not follow.
>
>The fact that one often wants to treat undef as "" or 0 without warning
>is in now way mutually exclusive with the idea that there are other
>times when you'd want that same warning promoted to an error.
You're right, of course. But since the OP seemed to want to do so on a
regular basis, I wouldn't count that strictly as "other times". Well,
before you tell me, I'll say it in the first place: indeed "under any
circumstance" logically is a particular instance of a "in a particular
circumstance". I agree. Yet, in common sense they describe somewhat
different situations. So all in all I would say that the two concepts
are not perfectly orthogonal, but let's say that they have a very
small internal product wrt their norms, and I still find *slightly*
surprising to want to have *that* warning promoted to an error.
use Carp;
use warnings;
warnings::warn(&testd, "uninitialized");
sub testd { confess("you hit an uninit string.");}
sub myinerror { print "$2"; }
sub myouterror { myinerror(); }
myouterror();
regards,
/iaw
[please! don't top post! snip all but the attribution and some
appropriate context and post your response underneath!]
> ok, now I want more than the little finger, but the entire hand. can I
> get a complete backtrace when I hit an unitialized string?
>
> use Carp;
> use warnings;
> warnings::warn(&testd, "uninitialized");
>
> sub testd { confess("you hit an uninit string.");}
> sub myinerror { print "$2"; }
> sub myouterror { myinerror(); }
> myouterror();
I think now you have to write your own __WARN__ handler. Here's my
15-second crack at it, this likely needs some tweaking:
#!/usr/bin/perl
use strict;
use Carp;
use warnings;
$SIG{__WARN__} = sub {
if ( $_[0] =~ m{ uninitialized }x ) {
confess('you hit an uninitialized string');
}
else {
print STDERR $_[0];
}
};
myouterror();
sub myinerror { print "$2"; }
sub myouterror { myinerror(); }
__END__
-jp