Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; my %hash_name = ( "one" => 1, "two" => 2, "three" => 3, "four" => 4 ); open MYFILE, ('/me/out.txt'); foreach my $line (<MYFILE>){ next if grep {$_ !~ keys %hash_name} $line; # above line seems to work but how do I find the hash key that match +ed? # OR is there a better way to do this altogether? } close(MYFILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Looping through a file to find a hash key
by 1nickt (Canon) on Mar 03, 2016 at 00:57 UTC | |
|
Re: Looping through a file to find a hash key ( quotemeta)
by Anonymous Monk on Mar 03, 2016 at 00:19 UTC |