SPUG: Clearing a variable in a package

DeRykus, Charles E charles.e.derykus at boeing.com
Tue Aug 17 17:33:23 CDT 2004


Just wondering why you want to reset Package::errstr
with every call...

Is there some reason you can't use errno's paradigm:
the error string is meaningful only if the method/sub's
return signals that an error has occurred. 



-----Original Message-----
From: Dan Ebert [mailto:mathin at mathin.com] 
Sent: Tuesday, August 17, 2004 9:55 AM
To: spug-list at mail.pm.org
Subject: SPUG: Clearing a variable in a package



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
----------------------------------------------------------


_____________________________________________________________
Seattle Perl Users Group Mailing List  
POST TO: spug-list at mail.pm.org  http://spugwiki.perlocity.org ACCOUNT CONFIG: http://mail.pm.org/mailman/listinfo/spug-list
MEETINGS: 3rd Tuesdays, Location Unknown
WEB PAGE: http://www.seattleperl.org



More information about the spug-list mailing list