Howdy List!

Quick question about Packages and an Error Variable.

I have a little package I made and can do;

 use MyGoodies;

 and can export the $MyGoodies::Error from it as well as a function.

What I'm trying to figure out is the best way to have a function return 0 on failure 
and set the Error Variable for me to use.

Is this the best way to do that:
        package MyGoodies;
        ...
        my $MyGoodies::Error; # declare the variable in the package and Export it and 
function().
        ...
        sub function {
                undef $MyGoodies::Error; # incase it was given a value before, right?
                my $r;
                ...
                ...
                if(everythign worked) { $r = 1; }
                elsif(it failed miserably) { $MyGoodies::Error = "It failed Miserably 
you loser - $@"; }

                return $r;
        }

#### 

In the script:

use MyGoodies;

        if(!function()) { print "The Sky is falling - $MyGoodies::Error"; }
        else { print "It seems to have worked ok in spite of your ignorance"; }

Is all of that the way that should work or am I missing something?

TIA

Dan

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

Reply via email to