Ace128 has asked for the wisdom of the Perl Monks concerning the following question:
This works, but Im sure there is some neater (perlish?), and maybe even some faster way to do the same?use strict; my @big = qw(a b c d e f g h i); my @small = qw(f c d g); my @keys_wanted = @small; foreach (@big) { my $found = 0; foreach my $already_there (@small) { if ($already_there eq $_) { $found = 1; last; } } if (!$found) { push (@keys_wanted, $_); } } print "@keys_wanted";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Keeping order, no duplicate and the complete keyset
by Roy Johnson (Monsignor) on Dec 07, 2005 at 21:51 UTC | |
|
Re: Keeping order, no duplicate and the complete keyset
by BrowserUk (Patriarch) on Dec 07, 2005 at 21:48 UTC | |
by ikegami (Patriarch) on Dec 07, 2005 at 22:46 UTC | |
by BrowserUk (Patriarch) on Dec 08, 2005 at 06:10 UTC | |
|
Re: Keeping order, no duplicate and the complete keyset
by planetscape (Chancellor) on Dec 08, 2005 at 07:56 UTC | |
|
Re: Keeping order, no duplicate and the complete keyset
by NetWallah (Canon) on Dec 08, 2005 at 05:58 UTC | |
|
Re: Keeping order, no duplicate and the complete keyset
by tphyahoo (Vicar) on Dec 08, 2005 at 11:48 UTC | |
|
Re: Keeping order, no duplicate and the complete keyset
by Ace128 (Hermit) on Dec 08, 2005 at 21:18 UTC |