use strict; use warnings; open my $fh, '<', 'C:\scripts\vacuum.txt', or die "Could not open file $!"; while (my $line = <$fh>) { print "line $. reading '$line'\n"; } #update: removed nonsense part as pointed by BrowserUk below #### -e File exists. -z File has zero size (is empty). -s File has nonzero size (returns size in bytes). >perl -we "use strict; my $file = 'c:\scripts\vacuum.txt'; if (-e -s $file){print qq(it exists and has not zero lenght\n)} else {print qq(exists but zero lenght\n)}" exists but zero lenght >perl -we "use strict; my $file = 'c:\scripts\002.txt'; if (-e -s $file){print qq(it exists and has not z ero lenght\n)} else {print qq(exists but zero lenght\n)}" it exists and has not zero lenght