Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re(2): RFC fetcher

by yakko (Friar)
on Apr 04, 2001 at 21:29 UTC ( #69761=note: print w/replies, xml ) Need Help??

in reply to Re: RFC fetcher
in thread RFC fetcher

Great ideas! Here's my implementation of the first idea:
#!/usr/bin/perl -w # example usage: rfc 1459 (gets the IRC RFC) use strict; use LWP::Simple qw(get); die("usage: rfc <rfc#>\n") unless defined($ARGV[0]); my $rfcnum=$ARGV[0]; my $base=""; my $rfcdir="$ENV{HOME}/rfcs"; my $rfcfile="${rfcdir}/rfc${rfcnum}.txt"; my $rfc; if(-e $rfcfile) { open(RFC,"<$rfcfile") or die("open($rfcfile): $!\n"); local $/ = undef; $rfc=<RFC>; close(RFC); } else { $rfc=get($base.$rfcnum.".txt"); open(RFC,">$rfcfile") or die("open($rfcfile): $!\n"); print RFC "$rfc"; close(RFC); } print "$rfc"; __END__
(Update: Just when I thought I had it nailed, better ideas crop up. Now reading docs to retool to merlyn's idea below. (tho doesn't appear to return the proper headers that support mirror()))

Me spell chucker work grate. Need grandma chicken

Replies are listed 'Best First'.
Re: Re(2): RFC fetcher
by merlyn (Sage) on Apr 04, 2001 at 21:45 UTC
    I'd use LWP::Simple's mirror($url, $localfile) in place of the if/else test. That way, if they update it, you'll get the latest version, and if it hasn't changed, it's still minimal traffic. It also automatically avoids creating the local file if the remote fetch failed, so you won't end up with an empty RFC file if something's broken.

    -- Randal L. Schwartz, Perl hacker

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://69761]
[talexb]: TStanley I'm flying to Vegas in two weeks time. After that flights leaving Vegas and Phoenix are late at night .. I've been hearing that it gets so hot that the air isn't dense enough for planes to take off. Weird. Guess you won't have that problem.
[Corion]: Yay, vacation time now - one week off work (but a Perl workshop in the middle ;)) )
[talexb]: TStanley I just realized that I was in your area for a convention back in April. We were at the high school for the weekend, the one with the long driveway. Nice spot.
[TStanley]: I am heading to Arlington, Virginia next week, then I get to spend an entire week at home. Looking forward to that as I will have spent 7 weeks on the road by the end of next week

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2017-06-23 14:16 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (548 votes). Check out past polls.