in reply to For Loop Output Errors
Your sample output data does not match your description, so it is hard to figure out what you want done.
That said, here is a starting point for getting started parsing the file.
Feel free to post questions if you do not understand the code, or the reasons it is coded that way.
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..$#stati +on_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.0 +0", $eqlong,"0.00",$eqdepth,"0.00",$numObs,$mag, "0.00", "\n"; } } print "Done\n";
"You're only given one little spark of madness. You mustn't lose it." - Robin Williams
|
|---|