Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Inappropriate I/O control operation

by talexb (Chancellor)
on Sep 26, 2017 at 18:09 UTC ( [id://1200140]=note: print w/replies, xml ) Need Help??


in reply to Inappropriate I/O control operation

I'm a little puzzled -- what problem are you trying to solve here?

If you're just looking to see if the file exists (seeing as you just open and close the file), why not just test for the existence of the file with -e? You could also check for whether the file's empty with -z.

I see an opportunity to use join on both your input and output ..

my $f = join ( '-', 'round1', $c, $f ) . '.txt'; my $exists = ( -e $f ) ? 'exists' : 'doesn\'t exist'; my $zero = ( -z $f ) ? 'empty' " 'not empty'; print join ( '-', $f, $c ) . ": $exists / $zero\n";
Coded but not tested. :)

PS Yeah, the $zero value is meaningless if the file doesn't exist.

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Edit: Fix inadvertent backslash in second paragraph.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found