in reply to Re^2: column counter and printf question
in thread column counter and printf question

toolic and scorpio17 have given you two ways to print out the columns. Here’s a variation on the theme:

while (my $line = <$input>) { next if 1 .. $line =~ /\@TYPE xy/; my @columns = split /\s+/, $line; printf $output "%8.3f", $columns[2]; printf $output " %10.3f", $columns[$_] for 3 .. $#columns; print $output "\n"; }

This makes use of the fact that for any array @array, the variable $#array contains the value of the highest array index. (Note that this is one less than the number of elements in the array, because array indices start at 0.)

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,