Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: "close" failing

by Herkum (Parson)
on May 31, 2006 at 12:55 UTC ( [id://552775]=note: print w/replies, xml ) Need Help??


in reply to "close" failing

When you are opening, printing to or closing a file you should always die. There can be things going on with a file besides you trying to write to it (for example someone deletes it while you still have it open). If you die it will tell you what it thinks is going on and gives you a hint that there may be something there that you need to look into.

Replies are listed 'Best First'.
Re^2: "close" failing
by arkturuz (Curate) on May 31, 2006 at 13:14 UTC
    You don't have to die always. $! will tell you the error.
    Also, in a web app it would be nice to inform the user that something is going wrong, instead of printing 'Internal Server Error' or sth similar.
      Another strange thing i found is that if i add ">", in front of abc.sh, it works for me. Can you tell what will ">" do to my script? open (SNMP1, ">abc.sh |") or die "Cannot run abc.sh $!"; while (<SNMP1>) { # do some processing } close (SNMP1) or die "ERROR: testing $! $?\n ";

        Please use the <code> tags!

        You will find you have create a file called abc.sh| in your current working directory. If you had warnings on you would also be warned about trying to read from a file handle opened for writing.

        /J\

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-19 05:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found