Jonathan Paton wrote:
if I make a module, say Foobar.pm how do you make it so if a function returns false you can die $!; ?
Return undef or 0, just like you are doing. Both your calls to baz have an argument, so 1 is returned both times. I prefer undef for false.
Thanks Jonathan for the input,
Actually its not because:
return 1 if shift;
is like doing
my $v = shift; return 1 if $v;
since $v is 0 its false :)
$ cat baz.pl #!/usr/bin/perl
use strict; use warnings;
baz(1) or die $!; baz(0) or die $!;
sub baz { return 1 if shift; # do what here to set $! = "You are not true"; properly, safely etc... ??? return 0; } $ perl baz.pl Died at baz.pl line 7. $
I know $! has some magic about intrenal error codes, and you just can't $! = 'reason it was false here';
I want to allow users to: baz() or die $!;
returning 0 or '' or undef will make it die() but I want to tell them why in $! if possible...
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>