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.pm
package 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); }
Test File: ./test.pl
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)


In reply to Perl Module Object - Return fail/success with a fault string by jhyland87

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.