Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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

by merlyn (Sage)
on Oct 15, 2000 at 15:09 UTC ( #36805=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 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;

Log In?

What's my password?
Create A New User
[Discipulus]: get them all printed on screen
Discipulus ;=)
[shmem]: silly question, silly answer:
[Discipulus]: i know, i know..
[shmem]: man perlfunc |perl -nle '$ok++ if /Alphabetical Listing of Perl Functions/;if($ok ){$s{$1}++if /^ (\w+)/}}{for(keys %s){$f="prototype \\\&CORE::$_"; eval"$f"||delete $CORE::{$_}}print for sort keys%CORE::'
[shmem]: well, there are some builtins which don't have a prototype...
[Discipulus]: eh eh.. i was looking in toke.c but dunno if is already used

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2017-05-23 10:02 GMT
Find Nodes?
    Voting Booth?