$file = "/path/to/file";
if (-s $file) {
# file has non-zero size.
} else {
# File is empty or does not exist.
}
####
$SIG{ALRM} = sub { die "Script took too long.\n" };
alarm(60); # Create alarm signal in 60 seconds.
# ... do long-running stuff.
alarm(0); # Cancel the alarm
####
END {
unlink($tmpfile);
}