use strict; use warnings; while( my $line = ) { next unless $. > 12; # $. contains current line number next if $line =~ /^$/; # skip blank lines chomp $line; # remove end-of-line character $line =~ s/\s+//; # strip leading whitespace my @columns = split(/\s+/, $line); # split columns on whitespace my $format = "%8.3f" . "%10.3f"x(@columns-3) . "\n"; printf $format, @columns[2..$#columns]; } # my guess at the input data __DATA__ SKIP 1 SKIP 2 SKIP 3 SKIP 4 SKIP 5 SKIP 6 SKIP 7 SKIP 8 SKIP 9 SKIP 10 SKIP 11 SKIP 12 Line_1 0.0 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 Line_2 0.0 0.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 Line_3 0.0 0.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 1.0 Line_4 0.0 0.0 4.0 5.0 6.0 7.0 8.0 9.0 1.0 2.0 Line_5 0.0 0.0 5.0 6.0 7.0 8.0 9.0 1.0 2.0 3.0