loris has asked for the wisdom of the Perl Monks concerning the following question:
Dear All,
I have an array of available things, an array of requested things and want to find which requested things are not available. I would like to do something like:
my @available_things = qw/ant bat cat dog /; my @requested_things = qw/bat rat/; my @not_available_requested_things = map {grep(!/$_/,@available_things)} @requested_things; print "available: @available_things\n"; print "requested: @requested_things\n"; print "requested, not available: @not_available_requested_things\n";
but this does not give me what I want (rat).
Can anyone enlighten me?
Thanks,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Matching array elements not in another array
by Corion (Patriarch) on Mar 18, 2009 at 14:56 UTC | |
|
Re: Matching array elements not in another array
by jethro (Monsignor) on Mar 18, 2009 at 15:05 UTC | |
|
Re: Matching array elements not in another array
by eff_i_g (Curate) on Mar 18, 2009 at 16:16 UTC | |
by locked_user sundialsvc4 (Abbot) on Mar 18, 2009 at 16:44 UTC | |
by loris (Hermit) on Mar 19, 2009 at 07:41 UTC |