Thanks for the reply!

> Sorry I don't understand your question well, but from 
> overall, I guess that's all about what you want...

I'll try to make it simpler, I have a tendency to ramble!

I've seen packages that have a variable like $Package::Error or $Package::errstr

I want a funtion in that package to return 1 on success or 0 on failure but 
if it is 0 I want to have the reason why it failed so I give $Package::Error a value.

#Main.pl

 use Package; # which exports the variable $Package::Error and the function function()

 if(!function()) { print "It failed and here is why - $Package::Error"; }
 else { print "It worked oh happy days"; }

#       or after executing function()

 if($Package::Error) { print "It failed and here is why - $Package::Error"; }
 else { print "It worked oh happy days"; }

#Package.pm

package Package;
... Export $Package:Error and function()
my $Package::Error;

sub function {
        undef $Package::Error; # in case it was given a value earlier in the script
        my $r = 1; # unless it fails return 1
        if(it failed to work) { 
                $r = 0; # it failed so return 0
                $Package::Error = "IT failed because ...."; # set the reason why into 
the Erro Variable
        }
        return $r;
}

Is that any clearer?

Thanks

Dan



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to