Take a command line filename and check if the file exists. I think this is a bashy way of doing this, but its useful nonetheless:
#!/usr/bin/perl use strict; die "usage: exist.pl file\n" unless defined($ARGV[0]); if (-e $ARGV[0]) { print "File exists!\n"; } else { print "File does not exist!\n"; }
The opposite can also be done. If you want to see if a file does not exist you can change the condition to:
if (! -e $ARGV[0]) { print "File does not exist!\n"; }
