Re: Spam:Re: using $! for die()ing with Package function

2004-12-03 Thread Lawrence Statton
> G'day... > > > 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. > > Ahh... But how do you set $! in the enclosing scope? > > Thanks... > > Regards, > I think the misunderstanding is: $!

Re: using $! for die()ing with Package function

2004-12-02 Thread JupiterHost.Net
I think as long as a failed open() or mkdir() (IE a system function that does $! sets it already) then that is all I need for this project: sub baz { mkdir '/dir/I/cant/make' or return; } will do what i need: baz or die $!; Actually mkdir returns true or false - sub baz{return mkdir '/dir/I/ca

RE: using $! for die()ing with Package function

2004-12-02 Thread Ron Goral
> -Original Message- > From: JupiterHost.Net [mailto:[EMAIL PROTECTED] > Sent: Thursday, December 02, 2004 7:15 PM > To: [EMAIL PROTECTED] > Subject: Re: using $! for die()ing with Package function > > > > > Paul Johnson wrote: > > > O

RE: Spam:Re: using $! for die()ing with Package function

2004-12-02 Thread Ron Goral
> -Original Message- > From: JupiterHost.Net [mailto:[EMAIL PROTECTED] > Sent: Thursday, December 02, 2004 7:06 PM > To: [EMAIL PROTECTED] > Subject: Re: Spam:Re: using $! for die()ing with Package function > > > > I don't think you can't set $! si

Re: using $! for die()ing with Package function

2004-12-02 Thread JupiterHost.Net
Paul Johnson wrote: On Thu, Dec 02, 2004 at 05:59:49PM -0600, JupiterHost.Net wrote: if I make a module, say Foobar.pm how do you make it so if a function returns false you can die $!; ? You can't. Or at least not in the sense you want. $! is linked to the current value of errno, which will be

Re: Spam:Re: using $! for die()ing with Package function

2004-12-02 Thread JupiterHost.Net
I think the misunderstanding is: $! is not a general purpose error message, it is a magical wrapper around errno() (read the section in perlvar) You *COULD* set $! to some numeric value selected from errno.h if there was one close enough to your message. But a user of your library getting "Di

Re: Spam:Re: using $! for die()ing with Package function

2004-12-02 Thread JupiterHost.Net
I don't think you can't set $! since it is a system var. Perhaps you could do something like: my $err_text; die $err_text if !Foo(); sub Foo_baz { return 1 if shift; $err_text = "Your error message." return 0; } Thanks Ron, yeah if I want to I'll have to pro

RE: Spam:Re: using $! for die()ing with Package function

2004-12-02 Thread Ron Goral
> -Original Message- > From: Michael Kraus [mailto:[EMAIL PROTECTED] > Sent: Thursday, December 02, 2004 6:43 PM > To: [EMAIL PROTECTED]; JupiterHost.Net; > [EMAIL PROTECTED] > Subject: RE: Spam:Re: using $! for die()ing with Package function > > > G'day.

Re: using $! for die()ing with Package function

2004-12-02 Thread JupiterHost.Net
JupiterHost.Net wrote: 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. Thank

Re: using $! for die()ing with Package function

2004-12-02 Thread Jonathan Paton
perldoc Carp; If that doesn't do what you want, then: perldoc -f eval else just set $@ and return undef. This is a bad solution I think. Jonathan Paton -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: using $! for die()ing with Package function

2004-12-02 Thread Paul Johnson
On Thu, Dec 02, 2004 at 05:59:49PM -0600, JupiterHost.Net wrote: > if I make a module, say Foobar.pm how do you make it so if a function > returns false you can die $!; ? You can't. Or at least not in the sense you want. $! is linked to the current value of errno, which will be set in the unde

Re: using $! for die()ing with Package function

2004-12-02 Thread JupiterHost.Net
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,

RE: Spam:Re: using $! for die()ing with Package function

2004-12-02 Thread Michael Kraus
G'day... > 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. Ahh... But how do you set $! in the enclosing scope? Thanks... Regards, Michael S. E. Kraus Software Developer Wild Technology Pty Lt

Re: using $! for die()ing with Package function

2004-12-02 Thread Jonathan Paton
> 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. Jonathan Paton -- To unsubscribe, e-mail: [EMAI

using $! for die()ing with Package function

2004-12-02 Thread JupiterHost.Net
Howdy folks, Here's something I was wondering (and wondering why its never come up sooner for me ;p) if I make a module, say Foobar.pm how do you make it so if a function returns false you can die $!; ? package Foobar; sub baz { return 1 if shift; # do what here to set $! = "You are not true"