kevyt has asked for the wisdom of the Perl Monks concerning the following question:
I know that it has to be simple but I can't figure it out. Can someone tell me what I am missing? Since I have posted this, I noticed that I am using grep wrong. Thanks Kevin$sic = 1711; $hash{$sic}{BUS} = 'Plumbing'; # A keyword in a business name $hash{$sic}{CAT} = 'Plumbing'; # Category $str[1] = 'Elite Plumbing'; foreach $sic (keys %hash){ # if the word in $hash{$sic}{BUS} is found in $str[1], # I want to know. # if ($hash{$sic}{BUS} =~ /$str[1]/) # This wont work. if (grep { $hash{$sic}{BUS} == $_ } $str[1] ){ # Nope # $str[38] = $hash{$sic}{CAT}; # $str[39] = $hash{$sic}{BUS}; print "Found one. Bus name is $str[1] and cat is " . $hash{$sic} +{CAT} . " and sic is " . $str[39] ."\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: searching a scalar for a word. Should I use grep?
by bobf (Monsignor) on Jun 23, 2007 at 04:12 UTC | |
by kevyt (Scribe) on Jun 23, 2007 at 04:39 UTC | |
by kevyt (Scribe) on Jun 23, 2007 at 04:25 UTC | |
|
Re: searching a scalar for a word. Should I use grep?
by GrandFather (Saint) on Jun 23, 2007 at 04:34 UTC |