nimdokk has asked for the wisdom of the Perl Monks concerning the following question:
The problem with this approach is pretty obvious: 'one' does not match anything in the second list, which would be what I want. However, 'red' matches 'red' but also shows as not matched on everything else. Basically, I think what I want is to find a string wherever it is in an array. I've tried playing with hashes (also grep) on this to see if the solution might be in that direction, but I'm at a loss as to where to go from here. I just need a prod in the right direction, not a full-blown solution.@rray1=('one','red','orange','brown','green','blue','scarlett','fourte +en'); @rray2=('red','orange','yellow','green','blue','indigo','violet'); foreach my $check (<@rray1>) { foreach my $item (<@rray2>) { if ($check ne $item) { <do something> } }#close foreach
thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Match string in array
by JediWizard (Deacon) on Oct 03, 2005 at 19:10 UTC | |
by nimdokk (Vicar) on Oct 03, 2005 at 19:29 UTC | |
|
Re: Match string in array
by ikegami (Patriarch) on Oct 03, 2005 at 19:46 UTC | |
|
Re: Match string in array
by Skeeve (Parson) on Oct 03, 2005 at 19:54 UTC | |
|
Re: Match string in array
by chester (Hermit) on Oct 03, 2005 at 19:15 UTC | |
|
Re: Match string in array
by polypompholyx (Chaplain) on Oct 03, 2005 at 19:09 UTC | |
|
Re: Match string in array
by gasho (Beadle) on Oct 03, 2005 at 19:09 UTC | |
by sauoq (Abbot) on Oct 03, 2005 at 19:18 UTC | |
|
Re: Match string in array
by Hue-Bond (Priest) on Oct 04, 2005 at 20:28 UTC |