SPUG: Clearing a variable in a package

Dan Ebert mathin at mathin.com
Tue Aug 17 11:55:08 CDT 2004


Hi,

I'm writing a module/package and want to have an error string variable
al a $Package::errstr which I can set to the error message (and have the
method return 0).

so you could write something like:

use Package;
my $p = new Package;
my $return = $p->dosomething();
if(!$return) { print $Package::errstr; }

Currently I make a global variable, $errstr, in the package (so from the
script's point of view it is $Package::errstr) and give it a value if an
error is encountered in any of the methods.

I want the variable to be reset with every call ... is there a way of
doing this without putting a $errstr = ''; at the begining of each
method/subroutine in the package?

(I hope I explained this well ...)

Thanks,

Dan.
----------------------------------------------------------
Immigration is the sincerest form of flattery.
	- Unknown
----------------------------------------------------------




More information about the spug-list mailing list