Jeri has asked for the wisdom of the Perl Monks concerning the following question:
Hi! I'm using some software within my perl script and need to identify whether in the input file is empty or not before the processing starts. What I've written below isn't working. Is there an easier way to do this than calling the system? I tried opening the file and looking at the first line, but the while loop interferes with my logic.
#!/usr/bin/perl5.8.8 use strict; use warnings; my $cmd = "-s /home/vcg/Documents/Trial/temp"; if (system($cmd) == 0) { print "File exists!"; } else { print "File does NOT exist!";}
Forever Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Check for an empty file
by ikegami (Patriarch) on Sep 22, 2011 at 18:56 UTC | |
by Jeri (Scribe) on Sep 22, 2011 at 19:04 UTC | |
by ChuckularOne (Prior) on Sep 23, 2011 at 12:36 UTC | |
by ikegami (Patriarch) on Sep 23, 2011 at 16:35 UTC | |
|
Re: Check for an empty file
by roboticus (Chancellor) on Sep 22, 2011 at 18:55 UTC |