in reply to Perlish way of doing this
A bit more perlish. Note that %a is not really necessary. And the keys could be pre-sorted.
#!/usr/bin/perl use strict; my @a = qw( AA BB CC DD EE FF ); my @a1 = qw( AA DD EE ); my @a2 = qw( AA BB CC FF ); my %a = map { $_ => 1 } @a; my %a1 = map { $_ => 1 } @a1; my %a2 = map { $_ => 1 } @a2; my (@tmp1, @tmp2); @tmp1 = map { exists $a1{$_} ? $_ : '##' } sort keys %a; @tmp2 = map { exists $a2{$_} ? $_ : '##' } sort keys %a; print join(',',@tmp1); print "\n"; print join(',',@tmp2); print "\n";
update: removed unnecessary parentheses
|
|---|