On Jan 17, 3:45 pm, [email protected] (David Christensen)
wrote:
> Ron Bergin wrote:
> > It's interesting that you found the warning message to be meaningless,
> > but the exact same message was helpful when you told the pragma to
> > raise the level of warnings to be fatal.
> > I should have said nearly the same message.  Both messages told you where
> > the problem was located and with that info it should have been easy to
> > find/fix the problem.  In my mind that's not meaningless.
>
> The root cause problem is that "perldoc -f print" does not describe what
> happens on error.  I've filed a perlbug report to this effect.
>

Actually it does this... as you discovered in the doc:

    Prints a string or a list of strings. Returns true if
    successful...

In this case, $! is EBADF or "Bad file descriptor" which might
be due to some obscure OS error unknown to perl. So perl
can't necessarily pinpoint the exact cause with a meaningful
message at this stage but at least first warns you about the
unopened  filehandle. (and that unopened filehandle warning,
as it turns out,  is certainly a cause of  EBADF).

And I'd agree that the docs should mention $! as perl does
here:

    unlink  Deletes a list of files. On success, it returns the
              number of files it successfully deleted. On failure,
              it returns false and sets $! (errno):

And  many other perl i/o docs omit mention that  $! gets
set and  if there's failure such as truncate, stat, link, ...

However,  $! may be generic and dying on an earlier warning
may not always be particularly meaningful in explaining what's
really happening as it did in your case.


--
Charles DeRykus


--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to