Can we get the rest of the way there? Of course we can.
Can we do it without array subscripts? Why, yes. We can always do it without array subscripts.
my $SPACE = q{ }; my $PRINTF = '%3s %3s %s %s %s %s'; # remember cells from previous row my @prev_cells = ( $SPACE ) x 6; while (<DATA>) { # append a dash to the first column substr($_, 1, 0, ' -'); my @cells = split /\t/, $_; # suppress display if same as above my @display_cells = map { $_ eq shift @prev_cells ? $SPACE : $_ } @cells; printf $PRINTF, @display_cells; @prev_cells = @cells; } __DATA__ 1 300 1_a 30 1_b 20 1 300 2_a 22 2_b 12 1 320 1_a 10 1_b 30 1 320 2_a 32 2_b 22 2 312 1_a 30 1_b 20 2 312 2_a 22 2_b 12 2 310 1_a 31 1_b 20 2 310 2_a 21 2_b 12
prints
1 - 300 1_a 30 1_b 20 2_a 22 2_b 12 320 1_a 10 1_b 30 2_a 32 2_b 22 2 - 312 1_a 30 1_b 20 2_a 22 2_b 12 310 1_a 31 1_b 20 2_a 21 2_b 12
In reply to Re^2: Loop, but print once.
by Narveson
in thread Loop, but print once.
by BioNrd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |