Mega Code Archive

 
Categories / Perl / File
 

Does file exist

#!/usr/bin/perl use strict; use warnings; foreach my $file ( @ARGV ) {    print( "Checking $file: " );    if ( -e $file ) {               print( "$file exists!\n" );       if ( -f $file ) {               print( "The file $file is:" );          print( " executable" ) if ( -x $file );          print( " readable" ) if ( -r $file );            print( " writable" ) if ( -w $file );            print( "\n" );          print( "It is ", -s $file, " bytes.\n" );       }       elsif ( -d $file ) {   # is it a directory?          print( "$file is a directory!\n" );       }    }    else {       print( "$file doesn't exist.\n" );    }    print( "\n" ); }