in reply to are they all there?
use Array::Lookup; my @required_items = qw(apple orange pear); @collections = ( [ 'apple', 'pear' ], ['banana'] ); foreach my $collection (@collections) { foreach my $required_item (@required_items) { lookup $required_item, $collection, \¬found; } } sub notfound { my $required_item = shift; my $collection = shift; push @{$collection}, $required_item; } foreach my $collection (@collections) { print "@{$collection}\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: are they all there?
by ikegami (Patriarch) on Aug 22, 2006 at 18:11 UTC |