Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How do I write to a file?

by chromatic (Archbishop)
on Mar 05, 2000 at 07:49 UTC ( #4891=note: print w/replies, xml ) Need Help??


in reply to How do I write to a file?

Always, ALWAYS check the return value of a command such as open: open INPUT "myfile.txt" || die "Cannot open file: $!"; This will save you hours of aggregate troubleshooting when your program fails silently. (The special variable $! contains the error message. Print it to discover why the file couldn't be opened.)

Replies are listed 'Best First'.
Re: Answer: How do I write to a file?
by I0 (Priest) on Apr 08, 2002 at 06:22 UTC
    #I think you meant either open INPUT, "myfile.txt" or die "Cannot open file: $!"; #or (open INPUT, "myfile.txt") || die "Cannot open file: $!"; #"myfile.txt" || die "Cannot open file: $!" is always true

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://4891]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2021-04-16 18:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?