On Wed, Mar 2, 2011 at 10:11 AM, Parag Kalra <paragka...@gmail.com> wrote:
Sorry for the top post. I should have done bottom post. :( # Untested > use strict; > use warnings; > > open my $fh, '<', my_file; > while(<$fh>){ > if ($_ !~ /my_string/) { > # Do something > } > } > > The other way would be on shell - > > # Untested > grep my_string my_file > if [ $? -eq 1 ] > then > echo "Do something" > fi > ~Parag > > > > On Wed, Mar 2, 2011 at 9:55 AM, Matt <lm7...@gmail.com> wrote: > >> I am looking for a simple way to test if a file does not contain a >> string. This is on a linux box. >> >> if myfile does not contain mystring { >> #do_something; >> } >> >> The file is basically a list of names and I want to test that a >> certain name is not in there. Is there an easy way to do that? >> >> -- >> To unsubscribe, e-mail: beginners-unsubscr...@perl.org >> For additional commands, e-mail: beginners-h...@perl.org >> http://learn.perl.org/ >> >> >> >