- Perl Script: File test operators

Below is simple perl script which demonstrate the usage if file test operator ..
Feel free to use and copy this script:

Source: cat file_status.pl
#!/usr/bin/perl

$FILE = "server.txt";

if ( -b $FILE ){
        print "$FILE is block device \n";
}
if ( -c $FILE ){
        print "$FILE is char device \n";
}
if ( -d $FILE ){
        print "$FILE is dirctory \n";
}
if ( -e $FILE ){
        print "$FILE exists \n";
}
if ( -f $FILE ){
        print "$FILE is ordinary file \n";
}
if ( -l $FILE ){
        print "$FILE is symbolic link \n";
}
if ( -o $FILE ){
        print "$FILE is owned by current user. \n";
}

Continue Reading...


source:http://linuxpoison.blogspot.com/2012/10/13578167753277.html