HI here is the code I am working on (in the program itself contains how the txtfile looks like
#!/usr/bin/perl -w # ## Copyright (c) 2007 University of Miami # my $pkgdoc = <<'EOD'; #/**------------------------------------------------------------------ +-------------- # @ file radiosondeparcer.pl # This scirpt parces the fetched radiosonde data from # the plymoth website. # # @ussage radiosondeparcer.pl ddd.hh.yyyy.index.txt # date: Jan 18, 2007 #--------------------------------------------------------------------- +-------------*/ EOD # $Log$ use strict; use warnings; use Getopt::Long; if (@ARGV <1) { print $pkgdoc; exit -1; } my $txtfile = shift; open (IN, $txtfile)||die "cannot open $txtfile for reading"; #/**------------------------------------------------------------------ +--------------- # Read important info on txtfile and add it to the hash # structurepassed in. # # # txtfiles look like this: # # # <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 +THE-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 +357.0 18.65 # 1 1000 113 28.8 23.8 74 5.0 25.1 95 12 302.0 305.4 298.2 +357.7 18.88 # 2 961 466 25.4 22.3 83 3.1 23.2 93 15 302.0 305.3 297.7 +354.9 17.91 # 3 925 802 23.2 19.4 79 3.8 20.5 95 15 303.0 305.9 296.4 +349.0 15.51 # 4 850 1536 19.0 14.0 73 5.0 15.7 95 14 306.0 308.3 294.7 +341.8 11.91 # 5 769 2390 14.2 8.2 67 6.0 10.5 96 11 309.8 311.4 293.6 +337.0 8.91 # 6 753 2568 12.4 10.5 88 1.9 11.2 97 11 309.7 311.7 294.8 +342.2 10.65 # 7 737 2748 11.8 6.8 71 5.0 8.8 100 11 310.9 312.5 293.6 +336.9 8.44 # 8 700 3178 9.4 4.4 71 5.0 6.5 110 11 312.9 314.3 293.4 +336.3 7.51 # ... # # #--------------------------------------------------------------------- +--------------*/ LINE: while (my $line = <IN>) { next LINE if ($line =~ /<TITLE>/); next LINE if ($line =~ /</center>/); my my ($LAT, $LON) = (split(' ', $line)[-4,-3]); next LINE if ($line =~ /Date\:/); next LINE if ($line =~ /Station\:/); next LINE if ($line =~ /WMO/); next LINE if ($line =~ /Latitude\:/); next LINE if ($line =~ /Longitude\:/); next LINE if ($line =~ /------------------------------------------ +-------------------------------------/); next LINE if ($line =~ /LEV/); next LINE if ($line =~ /mb/); my ($LEV, $PRES, $HGHT, $TEMP, $DEWP, $RH, $DD, $WETB, $DIR, $SPD +, $THETA, $THE-V, $THE-W, $THE-E, $W) = split (' ", $line); } open (OUT, ">$txtfile.reduced); print OUT "$LAT, $LON, $PRES, $HGHT, $TEMP, $DEWP, $DIR, $SPD\n"; close (IN); close (OUT);
Now here is the question in the third line of the txtfile how do I pull out the 4th and 3rd to last numbers and place them as $LAT, $LON. Another question: I want to pull out the print (OUT) info for only $LEV = sfc, $PRES = 850, 500, 250. The scf pressure changes all the time.

In reply to 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.