>>>>> "M" == Matt <lm7...@gmail.com> writes:
M> I am looking for a simple way to test if a file does not contain a M> string. This is on a linux box. M> if myfile does not contain mystring { M> #do_something; M> } M> The file is basically a list of names and I want to test that a M> certain name is not in there. Is there an easy way to do that? 2 lines will do it: use File::Slurp ; unless( read_file( $file ) =~ /$whatever/ ) { # do something } faster and cleaner than the line by line methods others have posted. and if you want even more speed, and the file is long, then shell out to the grep utility and it has an option to only show you if a line is/isn't in file. i normally don't recommend shelling out but that would likely be the fastest solution for a large file. uri -- Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/