[28878] in Perl-Users-Digest
Perl-Users Digest, Issue: 122 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 9 23:36:44 2007
Date: Fri, 9 Feb 2007 20:35:51 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 9 Feb 2007 Volume: 11 Number: 122
Today's topics:
Request for a PERL script to download files kentweb@goxroads.com
Re: Request for a PERL script to download files <news@lawshouse.org>
Re: Request for a PERL script to download files <BLOCKSPAMfishfry@your-mailbox.com>
Re: Request for a PERL script to download files <uri@stemsystems.com>
Re: Request for a PERL script to download files <john@castleamber.com>
Re: Request for a PERL script to download files <uri@stemsystems.com>
Re: Request for a PERL script to download files <zentara@highstream.net>
Re: Request for a PERL script to download files <mikeflan@earthlink.net>
Re: Request for a PERL script to download files <tadmc@augustmail.com>
Re: Request for a PERL script to download files <news@lawshouse.org>
Re: Request for a PERL script to download files <hjp-usenet2@hjp.at>
Re: Request for a PERL script to download files <hjp-usenet2@hjp.at>
Re: Request for a PERL script to download files anno4000@radom.zrz.tu-berlin.de
Re: Request for a PERL script to download files <uri@stemsystems.com>
Re: Request for a PERL script to download files anno4000@radom.zrz.tu-berlin.de
Searching for all Occurances and Evaling Them <deadpickle@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 3 Feb 2007 07:42:13 -0800
From: kentweb@goxroads.com
Subject: Request for a PERL script to download files
Message-Id: <1170517333.284412.80840@m58g2000cwm.googlegroups.com>
I would like to use a PERL script to logon to a web site, navigate web
pages, select links for files to be downloaded, then receive the
files. The names of the files will be dynamic changing daily. The
reason I want to use PERL to do this is to automate the process so a
person doesn't have to do it. Does anyone have an example script that
does something like this?
Thank you.
------------------------------
Date: Sat, 03 Feb 2007 18:18:30 +0000
From: Henry Law <news@lawshouse.org>
Subject: Re: Request for a PERL script to download files
Message-Id: <1170526708.12949.0@proxy00.news.clara.net>
kentweb@goxroads.com wrote:
> I would like to use a PERL script to logon to a web site, navigate web
> pages, select links for files to be downloaded, then receive the
> files. The names of the files will be dynamic changing daily. The
> reason I want to use PERL to do this is to automate the process so a
> person doesn't have to do it. Does anyone have an example script that
> does something like this?
First a piece of advice: read the posting guidelines for this group
before you post again. It will help you get better answers (and get a
more pleasant time, for reasons that the guidelines explain).
To do what you want will require use of various Perl (not PERL) modules,
which will probably include WWW::Mechanize; CPAN will tell you what it
can do and how to do it; you can also download it from there if you need to.
Use this URL to find examples of how to use it
http://www.google.com/search?hl=en&q=perl+mechanize+sample
Also possible is LWP::Simple which does more simple things (surprise!)
but is very easy to use and powerful enough for many purposes. Here's a
fragment to give you an idea (untested, not syntax checked)
use strict; use warnings;
use LWP::Simple;
my $url = "http://www.example.com";
my $html_source = get $url or die "Aaaaagh:$!";
# process the HTML text (there are Perl modules to help there too)
my $target_url = "http://www.example.com/some/address/on/target";
my $downloaded_file = get $target_url or die "Aiieee:$!";
open DOWN,'>',"/some/local/file" or die "Couldn't open:$!";
binmode DOWN;
print DOWN $downloaded_file;
close DOWN;
Go try something, write some code; start simple - leave out the logging
in stuff first, just see if you can download a known file. Post here if
you can't make it work. Then add other functions as you get more confident.
--
Henry Law Manchester, England
------------------------------
Date: Sat, 03 Feb 2007 19:45:06 -0800
From: fishfry <BLOCKSPAMfishfry@your-mailbox.com>
Subject: Re: Request for a PERL script to download files
Message-Id: <BLOCKSPAMfishfry-DFB43B.19450603022007@news.giganews.com>
In article <1170526708.12949.0@proxy00.news.clara.net>,
Henry Law <news@lawshouse.org> wrote:
> kentweb@goxroads.com wrote:
> > I would like to use a PERL script to logon to a web site, navigate web
> > pages, select links for files to be downloaded, then receive the
> > files. The names of the files will be dynamic changing daily. The
> > reason I want to use PERL to do this is to automate the process so a
> > person doesn't have to do it. Does anyone have an example script that
> > does something like this?
>
> First a piece of advice: read the posting guidelines for this group
> before you post again. It will help you get better answers (and get a
> more pleasant time, for reasons that the guidelines explain).
>
I've noticed that weekend volume is now down to less than 60 posts per
day. I think the Perl Usenet community has made its point by being so
inhospitable to newcomers over the years. And if you check out
Craigslist job listings for Perl, you'll see those are on the downslide
too.
How "there's more than one way to do it" morphed into "don't post here
till you've spent the day reading perldocs," is a sad story, in my
personal opinion.
------------------------------
Date: Sat, 03 Feb 2007 23:55:28 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Request for a PERL script to download files
Message-Id: <x7mz3ufrnj.fsf@mail.sysarch.com>
>>>>> "f" == fishfry <BLOCKSPAMfishfry@your-mailbox.com> writes:
f> I've noticed that weekend volume is now down to less than 60 posts per
f> day. I think the Perl Usenet community has made its point by being so
f> inhospitable to newcomers over the years. And if you check out
f> Craigslist job listings for Perl, you'll see those are on the downslide
f> too.
ever look at the volume on the perl jobs list? it has steadily rose over
several years now. anyone who know will post there instead of craig's
list as it is subscribed to by perl hackers from all over the world. and
craig's list charges for job postings in some cities now (boston for
sure). so your source of data is not that useful.
the issue is more like usenet overall is slowing down. or most newbies
find it from google and think it is a google service. also there are
dozens of topic specific perl mailing lists (see lists.perl.org), the
perl beginner's list, perlmonks, local monger lists, other bulletin
boards competing for perl discussions. so next time you feel like
indirectly flaming this group, please have some more accurate facts
behind you. the perl community isn't dying by any measure, just its
usenet slice is smaller by bit.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 4 Feb 2007 06:17:27 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Request for a PERL script to download files
Message-Id: <Xns98CD2F4B113Bcastleamber@130.133.1.4>
Uri Guttman <uri@stemsystems.com> wrote:
> the issue is more like usenet overall is slowing down.
Are there any solid numbers on that? I've been hearing the death of Usenet
for many years. What I have seen in those years was that more groups got
added. And yes, that thins out things.
> or most newbies
> find it from google and think it is a google service. also there are
> dozens of topic specific perl mailing lists (see lists.perl.org), the
> perl beginner's list, perlmonks, local monger lists, other bulletin
> boards competing for perl discussions. so next time you feel like
> indirectly flaming this group, please have some more accurate facts
> behind you. the perl community isn't dying by any measure, just its
> usenet slice is smaller by bit.
No idea if that's really the case. I mean, even Purl Gurl is back :-D.
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: Sun, 04 Feb 2007 02:08:40 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Request for a PERL script to download files
Message-Id: <x74pq2flhj.fsf@mail.sysarch.com>
>>>>> "JB" == John Bokma <john@castleamber.com> writes:
JB> Uri Guttman <uri@stemsystems.com> wrote:
>> the issue is more like usenet overall is slowing down.
JB> Are there any solid numbers on that? I've been hearing the death
JB> of Usenet for many years. What I have seen in those years was that
JB> more groups got added. And yes, that thins out things.
i don't think it is dying but it definitely has a smaller mindshare. in
its heyday it WAS the net (other than email).
>> or most newbies find it from google and think it is a google
>> service. also there are dozens of topic specific perl mailing lists
>> (see lists.perl.org), the perl beginner's list, perlmonks, local
>> monger lists, other bulletin boards competing for perl
>> discussions. so next time you feel like indirectly flaming this
>> group, please have some more accurate facts behind you. the perl
>> community isn't dying by any measure, just its usenet slice is
>> smaller by bit.
JB> No idea if that's really the case. I mean, even Purl Gurl is back :-D.
and just as delusional as before. we can only wait out moronzilla and it
will go away for another visit to the loony farm. we had like over a
year or two of peace this last time.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 04 Feb 2007 10:32:06 -0500
From: zentara <zentara@highstream.net>
Subject: Re: Request for a PERL script to download files
Message-Id: <2vubs2lq95hbm7d8gtqq4euej7k3rrv598@4ax.com>
On 3 Feb 2007 07:42:13 -0800, kentweb@goxroads.com wrote:
>I would like to use a PERL script to logon to a web site, navigate web
>pages, select links for files to be downloaded, then receive the
>files. The names of the files will be dynamic changing daily. The
>reason I want to use PERL to do this is to automate the process so a
>person doesn't have to do it. Does anyone have an example script that
>does something like this?
>
>Thank you.
Here I'll give you are break. You have separate opeartions,
the logon, the page retreival, the link extraction, and the individual
retrieval.
Googling and groups.googling will give examples of all those
steps, but here are some basics.
This script will download a single url. But you can get multiple
urls, by getting the page, using something like
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use WWW::Mechanize;
my $a = WWW::Mechanize->new();
$a->get( 'http://youtube.com/watch?v=2cBVpTRoMjI' );
print $_->url,"\n" for @{ $a->links };
__END__
You can also just use LWP::UserAgent instead of mechanize
to get the page, then extract the links manually, with
HTML::LinkExtor
You can groups.google search for examples of LinkExtor.
As a matter of fact, if you google enough, you will find scripts
that already do what you want, probably using curl or wget.
#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
# don't buffer the prints to make the status update
$| = 1;
my $ua = LWP::UserAgent->new();
my $received_size = 0;
my $url = 'http://zentara.net/zentara1.avi';
print "Fetching $url\n";
my $filename = substr( $url, rindex( $url, "/" ) + 1 );
#print "$filename\n";
open( IN, ">$filename" ) or die $!;
my $request_time = time;
my $last_update = 0;
my $response = $ua->get($url,
':content_cb' => \&callback,
':read_size_hint' => 8192,
);
print "\n";
close IN;
sub callback {
my ($data, $response, $protocol) = @_;
my $total_size = $response->header('Content-Length') || 0;
$received_size += length $data;
print IN $data;
# write the $data to a filehandle or whatever should happen
# with it here.
my $time_now = time;
# this to make the status only update once per second.
return unless $time_now > $last_update or $received_size ==
$total_size;
$last_update = $time_now;
print "\rReceived $received_size bytes";
printf " (%i%%)", (100/$total_size)*$received_size if $total_size;
printf " %6.1f/bps", $received_size/(($time_now-$request_time)||1)
if $received_size;
}
__END__
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: Sun, 04 Feb 2007 16:17:33 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Request for a PERL script to download files
Message-Id: <45C607CD.E0023632@earthlink.net>
Henry Law wrote:
> First a piece of advice: read the posting guidelines for this group
> before you post again. It will help you get better answers (and get a
> more pleasant time, for reasons that the guidelines explain).
>
> To do what you want will require use of various Perl (not PERL) modules,
> which will probably include WWW::Mechanize; CPAN will tell you what it
> can do and how to do it; you can also download it from there if you need to.
>
> Use this URL to find examples of how to use it
> http://www.google.com/search?hl=en&q=perl+mechanize+sample
snip
I'd like your opinion on the post below. I posted this on 1/20 and
was surprised when I got no response. Used to be you would
get at least 2 responses to any reasonable question. I suspect
that the lack of a response is primarily due to the lower
attendance in this group. If you have another explanation, I'd like
to hear it. Maybe the commercial product belongs to somebody
on this group? :-)
I never did solve that problem, but my need for it mostly went
away also.
Mike Flannigan
_______________________________________
What is the best way to do simple link extraction
from an FTP site using native Perl. I have native perl
HTML extraction scripts, and I can find the
packaged Extract Link programs on the web, but
I'd like a simple script that will do the job for me.
I'm surprised I can't find this on my own.
Is Net::FTP the way to go?
Mike Flannigan
------------------------------
Date: Sun, 4 Feb 2007 11:15:46 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Request for a PERL script to download files
Message-Id: <slrnesc562.65b.tadmc@tadmc30.august.net>
fishfry <BLOCKSPAMfishfry@your-mailbox.com> wrote:
> In article <1170526708.12949.0@proxy00.news.clara.net>,
> Henry Law <news@lawshouse.org> wrote:
>> First a piece of advice: read the posting guidelines for this group
>> before you post again. It will help you get better answers (and get a
>> more pleasant time, for reasons that the guidelines explain).
>>
>
> I've noticed that weekend volume is now down to less than 60 posts per
> day.
60 questions without readily available answers is better than 60 questions
without readily available answers along with 140 Frequently Asked Questions.
Reduced quantity is a _good_ thing if the quality is increased.
> I think the Perl Usenet community has made its point
That point being what? Checking the docs?
Perhaps _that_ is why there are less posts, because more people are
finding better answers in less time by checking the docs, and so
do not need to post here.
> by being so
> inhospitable to newcomers over the years.
We are not inhospitable to newcomers. We are inhospitable to people
who want us to read the docs to them.
> How "there's more than one way to do it" morphed into "don't post here
> till you've spent the day reading perldocs," is a sad story, in my
> personal opinion.
Yes it is.
How "never locking your front door" morphed into "always locking your
front door" is a sad story IMO, but that's what happens when the
Interstate comes to your small town.
Things change when a tight-knit community becomes open to
the General Public.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 04 Feb 2007 18:25:38 +0000
From: Henry Law <news@lawshouse.org>
Subject: Re: Request for a PERL script to download files
Message-Id: <1170613534.33547.0@demeter.uk.clara.net>
Mike Flannigan wrote:
> I'd like your opinion on the post below. I posted this on 1/20 and
> was surprised when I got no response. Used to be you would
> get at least 2 responses to any reasonable question.
> What is the best way to do simple link extraction
> from an FTP site using native Perl. I have native perl
> HTML extraction scripts, and I can find the
> packaged Extract Link programs on the web, but
> I'd like a simple script that will do the job for me.
> I'm surprised I can't find this on my own.
>
> Is Net::FTP the way to go?
I didn't answer it because I'm not good enough at this part of the Perl
universe. I do use Net::FTP and it works very well for what I use it
for (simple shipping around of files) but I think you probably know that
so I'd not be helping any by saying so.
--
Henry Law Manchester, England
------------------------------
Date: Sun, 4 Feb 2007 21:21:07 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Request for a PERL script to download files
Message-Id: <slrnescg1j.30u.hjp-usenet2@yoyo.hjp.at>
On 2007-02-04 16:17, Mike Flannigan <mikeflan@earthlink.net> wrote:
> I'd like your opinion on the post below. I posted this on 1/20 and
> was surprised when I got no response. Used to be you would
> get at least 2 responses to any reasonable question. I suspect
> that the lack of a response is primarily due to the lower
> attendance in this group. If you have another explanation, I'd like
> to hear it.
> _______________________________________
>
> What is the best way to do simple link extraction
> from an FTP site using native Perl.
[...]
> Is Net::FTP the way to go?
I didn't answer it because I didn't know what you meant with "simple
link extraction from an FTP site", because I'm not really familiar with
Net::FTP and because there were other postings to which I could
contribute more.
"Fishfry" may complain that there are now only 60 postings per day on
weekends but that is still way more than I can read, much less answer.
So I mostly just scan the group, often skipping entire threads and
answer only postings which for some reason catch my eye.
hp
--
_ | Peter J. Holzer | Es ist ganz einfach ihn zu verstehen, wenn
|_|_) | Sysadmin WSR | man nur alle wichtigen Worte im Satz durch
| | | hjp@hjp.at | andere ersetzt.
__/ | http://www.hjp.at/ | -- Nils Ketelsen in danr
------------------------------
Date: Sun, 4 Feb 2007 21:26:34 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Request for a PERL script to download files
Message-Id: <slrnescgbq.30u.hjp-usenet2@yoyo.hjp.at>
On 2007-02-04 06:17, John Bokma <john@castleamber.com> wrote:
> Uri Guttman <uri@stemsystems.com> wrote:
>> the issue is more like usenet overall is slowing down.
>
> Are there any solid numbers on that? I've been hearing the death of Usenet
> for many years. What I have seen in those years was that more groups got
> added. And yes, that thins out things.
I don't have numbers for the Big 8, but here they are for the de.*
hierarchy:
http://usenet.dex.de/de.ALL.html
As you can see the number of postings reached a maximum in 2001 and has
been declining ever since. The number of newsgroups has also been almost
constant since then.
hp
--
_ | Peter J. Holzer | Es ist ganz einfach ihn zu verstehen, wenn
|_|_) | Sysadmin WSR | man nur alle wichtigen Worte im Satz durch
| | | hjp@hjp.at | andere ersetzt.
__/ | http://www.hjp.at/ | -- Nils Ketelsen in danr
------------------------------
Date: 5 Feb 2007 14:46:55 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Request for a PERL script to download files
Message-Id: <52ouavF1p059gU1@mid.dfncis.de>
Uri Guttman <uri@stemsystems.com> wrote in comp.lang.perl.misc:
> >>>>> "JB" == John Bokma <john@castleamber.com> writes:
> JB> No idea if that's really the case. I mean, even Purl Gurl is back :-D.
>
> and just as delusional as before.
Uri, be fair. She's much less disruptive than she used to be. The
little I've read of the advice she's giving wasn't entirely off the
mark either. I've seen worse.
Anno
------------------------------
Date: Mon, 05 Feb 2007 09:59:47 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Request for a PERL script to download files
Message-Id: <x78xfcbqfw.fsf@mail.sysarch.com>
>>>>> "a" == anno4000 <anno4000@radom.zrz.tu-berlin.de> writes:
a> Uri Guttman <uri@stemsystems.com> wrote in comp.lang.perl.misc:
>> >>>>> "JB" == John Bokma <john@castleamber.com> writes:
JB> No idea if that's really the case. I mean, even Purl Gurl is back :-D.
>>
>> and just as delusional as before.
a> Uri, be fair. She's much less disruptive than she used to be. The
a> little I've read of the advice she's giving wasn't entirely off the
a> mark either. I've seen worse.
but it isn't coherent nor contributing well yet. still the same isolated
view of how things should be. and it infected the beginner's list
too. sure it may be less offensive but there is still plenty of just
wrong answers and lack of listening to others who know more. or worse,
not acknowledging that anyone else knows more. i am just making sure it
doesn't sucker newbies into its den of bad (perl) thinking.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 5 Feb 2007 15:14:10 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Request for a PERL script to download files
Message-Id: <52ovu2F1p0dn6U1@mid.dfncis.de>
Mike Flannigan <mikeflan@earthlink.net> wrote in comp.lang.perl.misc:
> Henry Law wrote:
[...]
> I'd like your opinion on the post below. I posted this on 1/20 and
> was surprised when I got no response. Used to be you would
> get at least 2 responses to any reasonable question. I suspect
> that the lack of a response is primarily due to the lower
> attendance in this group. If you have another explanation, I'd like
> to hear it. Maybe the commercial product belongs to somebody
> on this group? :-)
I don't remember the post specifically, but I've noted my
reactions now:
> _______________________________________
>
>
> What is the best way to do simple link extraction
> from an FTP site using native Perl.
In an HTML context, "link extraction" would mean scanning
the pages for links. What is "link extraction" in an FTP
context? I seriously don't know. That reduces my inclination
to try a reply.
> I have native perl
> HTML extraction scripts, and I can find the
> packaged Extract Link programs on the web, but
> I'd like a simple script that will do the job for me.
> I'm surprised I can't find this on my own.
That part does nothing to make he question more clear.
> Is Net::FTP the way to go?
Probably. Why didn't you look at the documentation and
see if it's promising? I'm not going to do it for you,
especially not knowing what exactly you're looking for.
So, on to the next posting.
Anno
------------------------------
Date: 8 Feb 2007 13:22:09 -0800
From: "deadpickle" <deadpickle@gmail.com>
Subject: Searching for all Occurances and Evaling Them
Message-Id: <1170969729.447056.254330@q2g2000cwa.googlegroups.com>
What I want to do is search for all matching strings (lets say KBQP
for example) within a file with ext .wmo. Then I want to compare thier
times which is the second string in the file (ends with Z). Next I
want to take the newest one and run it through the rest of the
program. Im not sure how to do this. I hope this makes sense.
CODE
==========================================================
use strict;
use warnings;
$\ = "\n";
open OUT,'>', 'asospf.txt' or die "cannot open 'asospf.txt' $!";
print OUT "Title: Metar Plots";
print OUT "RefreshSeconds: 20\n";
print OUT 'IconFile: 1, 15, 15, 7, 7, "cover.png"'; #file for cover
print OUT 'IconFile: 2, 27, 54, 2, 53, "barb.png"'; #file for wind
barbs
print OUT 'Font: 1, 12, 1, "Times New Roman"',"\n"; #font
close OUT;
open OUT,'>>', 'asospf.txt' or die "cannot open 'asospf.txt' $!";
#open output file/this part needs to be appended to my $year = '07';
my $month = '02';
my $day = '07';
my $hour = '19';
my $min = '00';
my $wmo = "07020719f.wmo";
open WMO, $wmo;
#Check WMO file for station metars aka stations starting with K
while (my $obs = <WMO>) {
if ($obs =~ m/^(K)/) {
my @a = split(" ", $obs);
#Matches the obs with the station data contain within stations.txt
open ID, '<', 'stations' or die "cannot open 'stations' $!";
while ( my $stations = <ID> ) {
next unless $stations =~ /\A.{20}($a[0]|A)\s+(.+)/;
my @id = split (" ",$2);
#Section reserved for comparing the time of the obs with current
time
#wmo variables
my $sday = substr($a[1], 0, 2);
my $shour = substr($a[1], 2, 2);
my $smin = substr($a[1], 4, 2);
my $totalsys = "$hour$min";
my $totalwmo = "$shour$smin";
#check for if days are equal
if ($day >= $sday || $day < $sday) {
#how old is the obs? checks by minusing 40 from the actual time
#compare the WMO time stamp to the system time to make sure it is
in positive realm
if ($totalsys >= $totalwmo) {
#check hour to see if the system time needs editing
#then check to see how old the obs is
if ($hour > $shour) {
my $age = ($totalsys-40)-$totalwmo;
if ($age < 20) {
}
elsif ($age >= 20 && $age < 30) {
my $color = "133 245 252";
print OUT "Color: $color";
}
elsif ($age >=30 && $age < 60) {
my $color = "239 165 52";
print OUT "Color: $color";
}
else {
my $color = "172 49 49";
print OUT "Color: $color";
}
}
elsif ($hour == $shour) {
my $age = $totalsys-$totalwmo;
if ($age < 20) {
my $color = "0 0 0";
print OUT "Color: $color";
}
elsif ($age >= 20 && $age < 30) {
my $color = "133 245 252";
print OUT "Color: $color";
}
elsif ($age >=30 && $age < 60) {
my $color = "239 165 52";
print OUT "Color: $color";
}
else {
my $color = "172 49 49";
print OUT "Color: $color";
}
}
}
elsif ($totalsys <= $totalwmo) {
my $age = ($totalsys+60)-($totalwmo-2300);
if ($age < 20) {
my $color = "0 0 0";
print OUT "Color: $color";
}
elsif ($age >= 20 && $age < 30) {
my $color = "133 245 252";
print OUT "Color: $color";
}
elsif ($age >=30 && $age < 60) {
my $color = "239 165 52";
print OUT "Color: $color";
}
else {
my $color = "172 49 49";
print OUT "Color: $color";
}
}
}
if (length($id[1]) == 5) { #with synop code
chop ($id[3]);
chop ($id[5]);
chomp $obs;
my $p = ".";
my $n = "-";
my $lat = $id[2]+($id[3]*(1/60));
my $rlat = sprintf("%.4f", $lat);
my $long = -($id[4]+($id[5]*(1/60)));
my $rlong = sprintf("%.4f", $long);
my @stid = ( $obs, $rlat, $rlong);
metarcode (@stid);
}
else { #without synop code
chop ($id[2]);
chop ($id[4]);
chomp $obs;
my $lat = $id[1]+($id[2]*(1/60));
my $rlat = sprintf("%.4f", $lat);
my $long = -($id[3]+($id[4]*(1/60)));
my $rlong = sprintf("%.4f", $long);
my @stid = ( $obs, $rlat, $rlong);
metarcode (@stid);
}
}
}
}
close (OUT);
FILE
=========================================================
KBQP 071845Z AUTO 35003KT 7SM OVC012 14/12 A3018 RMK AO2=
KBQP 071905Z AUTO 35003KT 7SM OVC012 14/12 A3018 RMK AO2=
KBQP 071925Z AUTO 35003KT 7SM OVC012 14/12 A3018 RMK AO2=
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 122
**************************************