The part that was strange was the negative return value. Anyway, I showed how to keep track of the re-tries, etc which was the main point.

In general, Perl does like C. There is some historical weirdness that we just have to live with. In Perl a .pm module has to return non-zero when "all is ok" (usually just by last line of 1;), but a Perl program returns (0) to the O/S if it works (*nix or Windoze). Perl should return a positive error code if it abends. This is strange and inconsistent and I'm not saying that it isn't.

For the most part the Perl functions and C functions do what you expect in terms of true/false. In C there is weirdness with EOF, that's -1. So, yes there are funcs that return negative values for "true". In Perl most of these weirdo cases have been solved and I'm not saying that they aren't. I've never tested a loop for an EOF value in Perl... the subject just doesn't come up.

I am saying that returning a negative number for an error code is a strange thing to do. If non-zero means a error code, then a positive number is far better than a negative number. For a T/F value, return either 0 or a positive number.


In reply to Re^5: How do I use a block as an ‘or’ clause instead of a simple die? by Marshall
in thread How do I use a block as an ‘or’ clause instead of a simple die? by boom

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.