Apologies in advance for the brutality, but your code is absolutely abonimable, and does not even compile.

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


In reply to Re: For Loop Output Errors by NetWallah
in thread For Loop Output Errors by Bama_Perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.