Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # `natsort` from Sort::Key::Natural would be better than `sort`.
- # To use this:
- # * Install the module,
- # * Pass the `-MSort::Key::Natural=natsort` switch to `perl`, and
- # * Replace the three instances of `sort` with `natsort`.
- perl -lane'
- $data{$F[1]}{$F[2]}{$F[3]} = $F[0];
- ++$cols{$F[3]};
- END {
- local $, = "\t";
- my @cols = sort keys(%cols);
- print undef, undef, @cols;
- for my $x (sort keys(%data)) {
- for my $y (sort keys(%{$data{$x}})) {
- print $x, $y, map { $data{$x}{$y}{$_} } @cols;
- }
- }
- }
- '
- # Output:
- # z1 z2
- # x1 x1 20
- # x1 y1 10 19
- # x2 y1 16 12
- # x2 y2 15
- # y1 y1 11
Add Comment
Please, Sign In to add comment