Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Re: Easy one: removing elements of one array from another...

by indapa (Monk)
on Jun 28, 2001 at 20:33 UTC ( #92360=note: print w/replies, xml ) Need Help??


in reply to Re: Easy one: removing elements of one array from another...
in thread Easy one: removing elements of one array from another...

Taken from Perl Cookbook 4.7:

#!/apps/bin/perl -w use strict; # Taken from Perl Cookbook 4.7 Finding Elements in One Array but # not another my %seen = (); # look up table my @goodWords; # words you want my @badWords=("jerk","store","king"); my @myArray=("jerry","wash","king","kong","store","when","jerk"); @seen{@badWords} = (); # build lookup table my $item; foreach $item (@myArray) { push (@goodWords, $item) unless exists $seen{$item}; } # print the contents of goodWords foreach (@goodWords) { print "$_\t"; } print "\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://92360]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2019-12-09 19:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?