in reply to Difference Quantity of two Arrays
You should really be thinking "hash" when you want to check if an item is in a set:
sub create_list { my @skip_dbs = @_; # declare the hash my %skippables; # populate the hash with the skippables $skippables{$_}++ for @skip_dbs; my @dbs = qw/fetch forward user smtp/; # return a list of each element of @dbs # that isn't in the skippables hash return grep { ! $skippables{$_} } @dbs; } my @list = create_list("user", "smtp"); print "@list";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Difference Quantity of two Arrays
by ocs (Monk) on Jan 02, 2007 at 14:54 UTC | |
by ikegami (Patriarch) on Jan 02, 2007 at 15:51 UTC |