Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Answer: How do I test whether a file has some contents or not?

by ybiC (Prior)
on Oct 15, 2000 at 17:13 UTC ( #36810=categorized answer: print w/replies, xml ) Need Help??

Q&A > files > How do I test whether a file has some contents or not? - Answer contributed by ybiC

Filetest operators can be found at perlfunc:_X.   Just a day or so ago swiftone showed me the "_" shortcut for performing multiple tests on one file.   Yet another way to look at it.
if (-s $file && -T _) { # do stuff with text file > 0bytes } if (-s $file && -B _) { # do stuff with binary file > 0bytes }

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2016-12-07 22:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (132 votes). Check out past polls.