Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

( #36810=categorized answer: print w/ replies, xml ) Need Help??

Q&A > files > How do I test whether a file has some contents or not? 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 }

Comment on Answer: How do I test whether a file has some contents or not?
Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2015-07-05 10:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls