Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

( #36805=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 merlyn

Hmm, on the off chance that "contents" is not "text", and believing the description more than the title, I'd also add:
print "it's a non-empty text-ish file" if -s $file and -T $file;

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 studying the Monastery: (4)
As of 2015-07-30 03:44 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 (269 votes), past polls