So I'm opening a .txt file with perl but I want it to check to make sure there is data written to the file and if not to end the program. So far all I can do is get it to run like there is data or run like there isn't any data regardless if there actually is. I've tried just about everything so at this point I've just made two .txt files and left one blank so I can see if wordlist.txt is equal to shit.txt and if they are to kill the program. Still isn't working though, if you could help that would be great!
my $wordlist = 'wordlist.txt'; my $highschool = 'bathroom.txt'; open (LIST, $wordlist) || die "\n Cannot find wordlist.txt \n"; open (lol, $highschool) || die "\n Cannot find bathroom.txt \n"; + print "\n professional site \n"; # After opening the two .txt files I'm checking if they are equal because bathroom.txt is a blank file if ($highschool =~ $LIST) { die "\n No data in wordlist.txt \n"; } else { print "\n All clear \n"};
In reply to Testing if a .txt file contains any data by sigmaaa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |