Created
December 2, 2014 20:51
-
-
Save moritz/4421c5e9ab0e5d994bac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use 5.014; | |
use warnings; | |
my @in = ( | |
[ 'b', 'c', 'f' ], | |
[ 'a', 'd' ], | |
[ 'c', 'd', 'e' ], | |
); | |
my %indexes = map {; $_ => 1} map @$_, @in; | |
my $count = scalar keys %indexes; | |
@indexes{sort keys %indexes} = 0 .. ($count - 1); | |
my @out = map { | |
my @new = (undef) x $count; | |
@new[ @indexes{@$_} ] = @$_; | |
\@new; | |
} @in; | |
use Data::Dumper; | |
print Dumper \@out; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment