The following does what it seems you want and cleans up your original code somewhat. Note however that modules such as HTML::TreeParser are generally much better (more reliable and easier to maintain) tools for extracting the raw data from an HTML page such as the source of this data seems to be.

use strict; use warnings; my $lat; my $long; # First seek location line while (<DATA>) { next unless /(-?\d+(?:\.\d*)?)\s+ (-?\d+(?:\.\d*)?)\s+ \d+\s \d+/ +x; ($lat, $long) = ($1, $2); last; } print "$lat, $long\n"; # Skip to data lines while (<DATA>) {last if /^-+$/}; while (<DATA>) {last if /^-+$/}; while (<DATA>) { my ($LEV, $PRES, $HGHT, $TEMP, $DEWP, $RH, $DD, $WETB, $DIR, $SP +D) = split ' '; last unless defined $SPD; print "$PRES, $HGHT, $TEMP, $DEWP, $DIR, $SPD\n"; } __DATA__ <TITLE>Plymouth State RAOB Thermodynamic Diagram/Data</TITLE> </center><pre> Miami Intl Airp FL US KMIA 1 25.82 -80.28 4 72202 Date: 0000Z 24 AUG 05 Station: KMIA WMO ident: 72202 Latitude: 25.82 Longitude: -80.28 Elevation: 4.00 ---------------------------------------------------------------------- +--------- LEV PRES HGHT TEMP DEWP RH DD WETB DIR SPD THETA THE-V THE-W TH +E-E W mb m C C % C C deg knt K K K +K g/kg ---------------------------------------------------------------------- +--------- SFC 1012 4 29.8 23.8 70 6.0 25.3 100 10 301.9 305.3 298.1 35 +7.0 18.65 1 1000 113 28.8 23.8 74 5.0 25.1 95 12 302.0 305.4 298.2 35 +7.7 18.88 2 961 466 25.4 22.3 83 3.1 23.2 93 15 302.0 305.3 297.7 35 +4.9 17.91 3 925 802 23.2 19.4 79 3.8 20.5 95 15 303.0 305.9 296.4 34 +9.0 15.51 4 850 1536 19.0 14.0 73 5.0 15.7 95 14 306.0 308.3 294.7 34 +1.8 11.91 5 769 2390 14.2 8.2 67 6.0 10.5 96 11 309.8 311.4 293.6 33 +7.0 8.91 6 753 2568 12.4 10.5 88 1.9 11.2 97 11 309.7 311.7 294.8 34 +2.2 10.65 7 737 2748 11.8 6.8 71 5.0 8.8 100 11 310.9 312.5 293.6 33 +6.9 8.44 8 700 3178 9.4 4.4 71 5.0 6.5 110 11 312.9 314.3 293.4 33 +6.3 7.51 </pre>

Prints:

25.82, -80.28 1012, 4, 29.8, 23.8, 100, 10 1000, 113, 28.8, 23.8, 95, 12 961, 466, 25.4, 22.3, 93, 15 925, 802, 23.2, 19.4, 95, 15 850, 1536, 19.0, 14.0, 95, 14 769, 2390, 14.2, 8.2, 96, 11 753, 2568, 12.4, 10.5, 97, 11 737, 2748, 11.8, 6.8, 100, 11 700, 3178, 9.4, 4.4, 110, 11

DWIM is Perl's answer to Gödel

In reply to Re: PARSER help by GrandFather
in thread PARSER help by MKevin

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.