I disagree with diotalevi: not all "interesting lines" start with a dot. I can see that those lines can be wrapped. An example of the file I just downloaded using wget:
.WEDNESDAY...MOSTLY SUNNY. HIGHS IN THE LOWER 50S. EAST WINDS 5 TO
10 MPH.
.WEDNESDAY NIGHT...MOSTLY CLEAR. LOWS IN THE UPPER 20S. EAST WINDS
5 TO 10 MPH.
.THANKSGIVING DAY...PARTLY SUNNY. HIGHS IN THE LOWER 50S.
See the wrapping in or around the wind speeds?
I think one easy way to unwrap such a short file, is to first collect the block you want, and then split on the dots that start a line. Something like:
@ARGV = 'paz049.txt';
my $buffer = '';
while(<>) {
if(s/^\.// .. /^$/) {
$buffer .= $_;
}
}
$buffer =~ s/\s+$//;
$buffer =~ s/\n(?!\.)/ /g;
my @lines = split /\s*\n\./, $buffer;
If I now print out all the data in @lines, I seem to get the proper result:
| [reply] [d/l] [select] |
Thanks bart,
I'm evaluating Geo::WeatherNOAA but I want to learn more about perl. I look forward to trying out this code.
BR
| [reply] |
Have you looked at Geo::WeatherNOAA on CPAN? According to the POD:
This module is intended to interpret the NOAA zone forecasts and current city hourly data files. It should give a programmer an easy time to use the data instead of having to mine it. | [reply] |
Thanks! Penfold suggested this module earlier. I loaded the other prereq's and I'm trying it out. I'll let everyone know how it goes.
| [reply] |
| [reply] |
I look forward to checking out the links you provided. I'm really enjoying this exercise. When a script has a print command in it, how can you send that to a file?
| [reply] |
open SOMEFILE, '>', $filename;
# Then...
print SOMEFILE "Blah, blah, blah";
Alternately, from outside the script, when calling it, most operating
environments provide a way to redirect the standard output of the script
to a file. For instance, in a POSIX-like environment you can use
tee or a shell redirection operator (usually > in
most Unix-style shells, and also in DOS, OS/2, and NT, among others).
If you need more specific information about this, you'll have to
specify more details about your operating environment.
Sanity? Oh, yeah, I've got all kinds of sanity. In fact, I've developed whole new kinds of sanity. You can just call me "Mister Sanity". Why, I've got so much sanity it's driving me crazy.
| [reply] [d/l] [select] |
No idea what you mean when you say "think Walmart TV", but maybe this could do something like what you seem to require (without the need for batch files):
use strict;
use warnings;
use LWP::Simple;
my $url = 'http://weather.noaa.gov/pub/data/forecasts/zone/pa/paz049.t
+xt';
my @content = grep s/^\.//, split "\n", get $url
or die "Couldn't get it!\n";
print join "\n", @content;
| [reply] [d/l] |
Walmart TV is the in-house TV's running advertisment. Our system has ads and a weather ticker.
I'm currently evaluating Get::WeatherNOAA but I want to learn some perl so I'm going to try what you sent. I have LWP::Simple loaded so trying that code should be a pretty easy. I need to learn how to handle output now.
Thanks!
| [reply] |
correction: Geo::WeatherNOAA
| [reply] |