my @test1 = qw( 1 1 2 2 3 3 4 4 5 5 6 6 7 7 ); my @test2 = qw( 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 ); # unzip @test1, we know to make it two lists my $unzipped = unzip( 2, @test1 ); $unzipped = [ [ 1, 2, 3, 4, 5, 6, 7 ], [ 1, 2, 3, 4, 5, 6, 7 ], ] # unzip @test2, we know to make it three lists my $unzipped = unzip( 3, @test2 ); $unzipped = [ [ 1, 2, 3, 4, 5, 6, 7 ], [ 1, 2, 3, 4, 5, 6, 7 ], [ 1, 2, 3, 4, 5, 6, 7 ], ]