http://www.perlmonks.org?node_id=1044638


in reply to Re: Create a list from an Arrray
in thread Create a list from an Arrray

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