use strict; use warnings; open(my $inp, "test.mcp_list") or die "Could not open mcp_list: $!"; my @station_cols = qw|station mcccdelay std cccoeff ccstd pol t0_times delay_time1 delay_time2|; my @stations; while (<$inp>){ my @line = split; if (9 == @line){ push @stations, {map {$station_cols[$_] => $line[$_]} 0..$#station_cols }; next; } my $numObs = @stations; if ($line[0] eq "PDE"){ my ($PDE,$year,$month,$day,$hour,$minute,$second,$eqlat,$eqlong,$eqdepth,undef, $mag) = @line; printf "%2d%2d%2d%2d%2d %s %s%7.3f %s%8.3f %s%6.2f %s %s %s %s \n", $year%100,$month,$day,$hour,$minute,$second,"0.00",$eqlat,"0.00", $eqlong,"0.00",$eqdepth,"0.00",$numObs,$mag, "0.00", "\n"; } } print "Done\n";