Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Summing up: two arrays, both with strings as elements; I need to find which strings in @triple matches as substrings of @quadruple. Example "United Nations Children Fund" in @quadruple should match against "United Nations Children" in @triple. That done, I need to remove the matched string from @triple WITHOUT leaving an undef hole, cause I have to process that array the same way later. Hope it is clear. Thanks a lot for any help and suggestion. Livius# @quadruple contains longer strings # @triple contains shorter strings foreach $aaaa(@quadruple) { $idx = 0; while ($triple[$idx]) { if ($aaaa =~(/$triple[$idx]/gs)) {push (@common1, $idx); } $idx++; } } foreach $xx(@common1) {splice (@triple,$xx,1) }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: searching in array elements substrings contained in another array
by eff_i_g (Curate) on Nov 17, 2008 at 20:42 UTC | |
by Anonymous Monk on Nov 17, 2008 at 21:06 UTC | |
|
Re: searching in array elements substrings contained in another array
by ccn (Vicar) on Nov 17, 2008 at 20:13 UTC | |
by Anonymous Monk on Nov 17, 2008 at 20:30 UTC | |
by ccn (Vicar) on Nov 17, 2008 at 20:37 UTC | |
by Anonymous Monk on Nov 17, 2008 at 20:56 UTC |