The "do" module should return true on success
May I ask how you could justify the should in your sentence? I read the perldoc again, but am unable to find any recommendation on the return value. In particular, it does not say that the user should signal an error by returning false. The only reference which I could found to require is, that do should not be used to load modules.

IMHO, the best use for do is in those cases, where you want to evaluate at run-time Perl code which happens to be stored in a file. Without do, you would have to open the file, read it and eval the result. do is a shorthand way for doing this, but it means that a return value of undef (or other false value, such as 0 or '') should not be required to have a special meaning of 'failure'. The present implementation of do would nearly perfectly do this job, if it would not suffer from the single restriction that the caller can not distinugish between the case of the code in the filename returning undef, or Perl being unable to open the file. Moreover, this flaw in the implementation shows up only if the file does not end in a newline, and it would be easy to correct.

So, technically speaking, you are right in that the documentation indeed allows for this behaviour. But isn't it a pity that we could make a function much more useful, by just a minor change in implementation? Anyway, the question which I used when starting this thread, is answered: It is not a bug, but undefined behaviour, and it means that I have to restrict what our users are permitted to place into the file which our application will do...
-- 
Ronald Fischer <ynnor@mm.st>

In reply to Re^4: Why do we need a \n with do FILENAME? by rovf
in thread Why do we need a \n with do FILENAME? by rovf

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.