in reply to Check for an empty file

You could use Perl's -s instead of the shell's.

if (-s "/home/vcg/Documents/Trial/temp")

Note that empty (-z or !-s) and non-existent (!-e) are different things.

Replies are listed 'Best First'.
Re^2: Check for an empty file
by Jeri (Scribe) on Sep 22, 2011 at 19:04 UTC
    Thanks! It's working great! I'd prefer not to use the shell if I can help it!
Re^2: Check for an empty file
by ChuckularOne (Prior) on Sep 23, 2011 at 12:36 UTC
    I had some trouble with this a while back. -s returns a zero if the file is either zero bytes or nonexistent. It got a bit confusing until I worked out what was happening.

      Actually, it returns undef (and sets $!) if the file is non-existent.