Perl,
pasted
on Dec 3:
|
#!/usr/bin/perl
use strict;
use warnings;
my @a = ( 'b', 'c', 'f' );
my @b = ( 'a', 'd' );
my @c = ( 'c', 'd', 'e' );
my %seen;
my @suniq = sort grep {!$seen{$_}++} @a, @b, @c;
foreach my $arr (\@a, \@b, \@c) {
my %th = map { ( $_ => 1 ) } @$arr;
@$arr = map { $th{$_} ? $_ : undef } @suniq;
}
use Data::Dumper;
print Dumper(\@a,\@b,\@c);
|
Output:
|
$VAR1 = [
undef,
'b',
'c',
undef,
undef,
'f'
];
$VAR2 = [
'a',
undef,
undef,
'd',
undef,
undef
];
$VAR3 = [
undef,
undef,
'c',
'd',
'e',
undef
];
|
|