Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

\n characters in warn and die

by dmckee (Scribe)
on Mar 01, 2001 at 00:02 UTC ( [id://61414]=perlquestion: print w/replies, xml ) Need Help??

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"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://61414]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 10:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found