in reply to are they all there?
Since, as you say, your 'collections' are strings, you could consider something like the following:
my @required = qw ( apple banana orange pear ); my @collections = ( 'foo pear bar apple', 'apple foo pear orange banana', 'pineapple appearance', ); foreach my $collection ( @collections ) { foreach my $item ( @required ) { $collection .= " $item" unless $collection =~ /\b$item\b/; } } print "$_\n" for @collections;
Update: ikegami++ (see below). I haven't changed the code in this node, but please use the suggested improvement.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: are they all there?
by ikegami (Patriarch) on Aug 22, 2006 at 18:30 UTC | |
by ikegami (Patriarch) on Aug 23, 2006 at 19:24 UTC |