jhyland87 has asked for the wisdom of the Perl Monks concerning the following question:
So I am creating my first perl module, (atleast my first advanced one thats more than a few lines of code), and hope to submit it to CPAN, so id like to get it working perfectly
Right now, im trying to get the subroutines to return both a standard return code (0 or non 0), with a "fault code"
I guess heres an example of the current code (not really, but this is basically an example of what I have, in the relative aspect)
File: ./Module/Test.pmTest File: ./test.plpackage Test.pm; sub new { my ($self, $value) = (@_); my @return %return = ("code" => 1, "fault" => "You didnt even send a value to + me!\n") if (!$value); %return = ("code" => 0, "value" => "Cool, you sent me $value\n") i +f ($value); }
use Module::Test; $test = Module::Test->new(); die($test->{'fault'}) if (!$test); # Didn't die print $test->{'value'} if ($test);
Kinda get what I mean? Return both an exit code, as well as a comment that I can reference? THE ABOVE CODE IS NOT TESTED!! In fact, I doubt it works, so don't diagnose that, im just trying to get the idea of my goal to you through a code example...
Thanks in advance! (and yes, I googled it)
|
|---|