in reply to Create a list from an Arrray

You want to know which entries are in both lists:

my %matched; @matched{@STATIClist} = (); print "Valid tags:\n"; print "\t$_\n" for grep { exists $matched{$_} } @USERlist;

If you want to store the list...:

my @valid_tag = grep { exists $matched{$_} } @USERlist;

Dave

Replies are listed 'Best First'.
Re^2: Create a list from an Arrray
by Skeeve (Parson) on Jul 16, 2013 at 18:26 UTC

    What about good old hash functions?

    use Data::Dumper my(@list_a)=(qw(a b c d e f g)); my(@list_b)=(qw(a c e g h j k)); my(%just_a,%just_b,%both); @just_a{@list_a}=(); delete @just_a{@list_b}; @just_b{@list_b}=(); delete @just_b{@list_a}; @both{@list_a}=(); delete @both{keys %just_a}; print Data::Dumper->Dump([ [keys %just_a],[keys %just_b],[keys %both] ], [qw/just_a just_b both/] )
    Output:
    $just_a = [ 'b', 'd', 'f' ]; $just_b = [ 'k', 'h', 'j' ]; $both = [ 'e', 'c', 'a', 'g' ];

    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e