Your code is a complete train wreck so I'm not going to even try and guess where your head is at. Instead, working from your specification, I guess you want something like:

use strict; use warnings; while (defined (my $header = <DATA>)) { my @parts = split ' ', $header, 17; next if @parts < 12; processEvent (); print join (' ', @parts[3, 4, 6, 5, 7, 8, 11]), "\n"; } sub processEvent { <DATA>; for (1 .. 8) { my $line = <DATA>; last if ! defined $line; my @parts = split ' ', $line; splice @parts, 3, (@parts - 3) if @parts > 3; s/[^\d\s.]+/ /g for @parts[1 .. $#parts]; s/^\s+|\s+$//g for @parts; print join (' ', @parts), "\n"; } } __DATA__ 82 2 22 1043 54.7 48.020 114.037 17.5 3.2 2.9 13 177 84.3 0.20 +1.6 2.7 C MBMG * 3.1 KALISPELL VALLEY; FELT 3.07 82022210 BUT EP4432.804ES60.7 LRM IPD4435.40 IS67.2 180. AMM IPD4429.50 ES57.3 133. MSO EPC4415.90 ES32.3 CMT EP4430.50 IS58.3 LDM IPC4412.20 ES24.3 3 RXF EPC4414.3 CLX IPC4408.70 ES19.7

which prints:

BUT 4432.804 60.7 LRM 4435.40 67.2 AMM 4429.50 57.3 MSO 4415.90 32.3 CMT 4430.50 58.3 LDM 4412.20 24.3 RXF 4414.3 CLX 4408.70 19.7 1043 54.7 114.037 48.020 17.5 3.2 177

Note that this code is not at all robust and depends on the event records' layout being consistent.

True laziness is hard work

In reply to Re^3: Lexical scope by GrandFather
in thread Lexical scope by velocitymodel

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.