in reply to For Loop Output Errors
I suggest to collect station data lines into a hash (%station_data) and then use collected data right after the 'PDE' line has been read.
use strict; use warnings; use diagnostics; use Data::Dumper; my $num_obs; my %station_data; while (<DATA>) { chomp; my @line = split; if (@line == 9) { $num_obs++; $station_data{$line[0]} = \@line; } elsif (/^PDE/) { my (undef, $year, $month, $day, $hour, $minute, $second, $eqlat, $ +eqlong, $eqdepth, $mag) = @line; # y m d h m s la lo de no mag printf "%02d%02d%02d %02d%02d%.2f %f %f %f %d %f\n", $year%100, $month, $day, $hour, $minute, $second, $eqlat, $eql +ong, $eqdepth, $num_obs, $mag; # process station data in according to your needs print Dumper(\%station_data) . "\n"; } } __DATA__ MCCC processed: unknown event at: Tue, 21 Oct 2014 13:39:56 CST station, mccc delay, std, cc coeff, cc std, pol , t0_times + , delay_times ZJ.APRL 0.5735 0.0270 0.8548 0.1060 0 APRL.BHZ 301 +.0824 -1.0954 ZJ.BEBP 0.0431 0.0173 0.8982 0.0495 0 BEBP.BHZ 300 +.6827 -1.2262 ZJ.DUBY -0.3951 0.0242 0.8635 0.0550 0 DUBY.BHZ 300 +.9965 -1.9781 ZJ.FOOT 0.4722 0.0570 0.7965 0.0987 0 FOOT.BHZ 301 +.2407 -1.3550 ZJ.GRAW -0.2962 0.0203 0.8875 0.0789 0 GRAW.BHZ 300 +.5646 -1.4473 ZJ.KNYN 0.2933 0.0428 0.7879 0.1305 0 KNYN.BHZ 301 +.3060 -1.5992 ZJ.LEON 0.5243 0.0235 0.8996 0.0634 0 LEON.BHZ 300 +.4850 -0.5473 ZJ.MICH -0.1824 0.0165 0.8599 0.0713 0 MICH.BHZ 300 +.1649 -0.9339 ZJ.RAPH 0.3076 0.0422 0.8096 0.0954 0 RAPH.BHZ 300 +.4645 -0.7435 ZJ.RKST -0.7187 0.0401 0.8060 0.0827 0 RKST.BHZ 300 +.3940 -1.6992 ZJ.SAMH -0.0702 0.0260 0.8930 0.0465 0 SAMH.BHZ 301 +.0272 -1.6839 ZJ.SHRD -0.3952 0.0319 0.8343 0.0938 0 SHRD.BHZ 300 +.8002 -1.7819 ZJ.SPLN -0.1563 0.0306 0.8653 0.0878 0 SPLN.BHZ 300 +.5314 -1.2742 Mean_arrival_time: 299.4135 No weighting of equations. Window: 3.19 Inset: 1.28 Shift: 0.25 Variance: 0.03135 Coefficient: 0.85047 Sample rate: 40.000 Taper: 0.40 Phase: P PDE 2013 4 20 3 47 55.02 -5.002 152.111 65.3 0.0 5.6
|
|---|