in reply to comparing element in arrays
EDIT:added \D around the variable in the REGEX after smoss's response. That should take care of the extra elements your were getting. The way it was before it would pick out 96 in the string if one of the numbers was either 9 or 6, adding the non number boundary should force it to match numbers exactly. It works on my tests. If it still doesn't work for you give me your sample data and I'll see if I can recreate the problem.foreach $element (@a) { foreach $number (@b) { if ($element =~ /\D$number\D/) { push (@c, $element); } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: comparing element in arrays
by smoss (Acolyte) on May 20, 2002 at 08:54 UTC | |
|
Re: Re: comparing element in arrays
by smoss (Acolyte) on May 20, 2002 at 12:04 UTC |