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

###############################
# Main.pl
use MyGoodies;
my $fedback = $MyGoodies::Error();

###############################
# MyGoodies.pm
package MyGoodies;
use strict;

sub Error
{    check smth and do smth
        return 1 if (everything goes fine)
}
1; # Don't miss it, or your package won't run.
###############################

But that's quite confuse.... you return 1 while everything
alright, but, your sub name is Error..... So the 1 means
OK or Error ?

HTH

----- Original Message ----- 
From: "Dan Muey" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 29, 2003 12:58 AM
Subject: Error Variable in Package


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]




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

Reply via email to