dmckee has asked for the wisdom of the Perl Monks concerning the following question:

I'm not sure if this is documented anywhere, or is an inadvertant feature, but the following two lines of code:
open FH, "<filedoesnotexist" or warn "$!\n"; open FH, "<filedoesnotexist" or warn "$!";
produce different output. Line one merely prints the standard error ('No such file or directory') whilst Line two prints the full "No such file or directory at C:\WIN98\DESKTOP\TEST.PL line 2."

Is this a undocumented feature (I looked at warn and die in perlfunc as well as $! in perlvar. Oh, and it's windows, so YMMV.

Replies are listed 'Best First'.
(tye)Re: \n characters in warn and die
by tye (Sage) on Mar 01, 2001 at 00:03 UTC

    "perldoc -f die", third paragraph:

    If the value of EXPR does not end in a newline, the current script line number and input line number (if any) are also printed, and a newline is supplied. Note that the "input line number" (also known as "chunk") is subject to whatever notion of "line" happens to be currently in effect, and is also available as the special variable `$.'. See the section on "$/" in the perlvar manpage and the section on "$." in the perlvar manpage.

            - tye (but my friends call me "Tye")
      /me slaps head, shouts DOH! and walks into suicide booth chanting "I must RTFM properly, I must RTFM properly"