Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: opened file being overwritten

by Anonymous Monk
on Dec 13, 2012 at 22:07 UTC ( [id://1008736]=note: print w/replies, xml ) Need Help??


in reply to Re^2: opened file being overwritten
in thread opened file being overwritten

Another large bug in your code is that due to operator precedence, your dies won't work.

Basically, open FILE1,">$_[0]" || die "could not open $_[0]" is being interpreted as open FILE1,(">$_[0]" || die "could not open $_[0]")

$ perl -MO=Deparse -e 'open INP, "<", "hello" || die $!' + open INP, '<', 'hello'; -e syntax OK $ perl -MO=Deparse -e 'open(INP, "<", "hello") || die $!' + die $! unless open INP, '<', 'hello'; -e syntax OK $ perl -MO=Deparse -e 'open INP, "<", "hello" or die "could not open: +$!"' die $! unless open INP, '<', 'hello'; -e syntax OK

You either need to use the lower-precedence or operator or call the open() function with parentheses.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-03-29 14:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found