if(-T $file) { print "$file is an ascii text file \n"; } else { print "Not an ascii text file \n"; } #### my $ft = File::Type->new(); my $type = $ft->mime_type($file); if ( $type eq "application/octet-stream" ) { do this.. } else { do that.. }