pico filetest1.pl
#!/usr/bin/perl -w
#inherent file testing functions
$file = "test";
if (-e $file) # '-e' tests if the file exists
{
print "file exists!";
}
if (-z $file) # '-z' tests if the file is a zero bytes file
{
print "file exists and has 0 bytes";
}
if (-f $file) # '-f' tests if the file is a file
{
print "file exists and is a file";
}
if (-d $file) # '-d' tests if the directory is a directory
{
print "directory exists and is a directory";
}
#end
perldoc -f -X #documentation regarding files
No comments:
Post a Comment