Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Perl on Windows XP needs to grab internet txt file.

by Jim (Curate)
on Feb 02, 2008 at 23:17 UTC ( #665777=note: print w/replies, xml ) Need Help??


in reply to Perl on Windows XP needs to grab internet txt file.

Consider using LWP::Simple::mirror for your specific task. There's a good example of its use in the article about LWP::Simple on the 22nd day of the 2003 Perl Advent Calendar.

Here's my own example:

#!C:/Perl/bin/perl.exe use strict; use warnings; use LWP::Simple qw( mirror is_error RC_NOT_MODIFIED ); my $url = 'http://rabbit.eng.miami.edu/dics/pocket.txt'; my $file = $url; $file =~ s{.*/}{}; my $status = mirror($url, $file); if (is_error($status)) { die "Can't get text file at URL $url\n"; } if ($status == RC_NOT_MODIFIED) { warn "File $file not modified\n"; } # Do something with freshened file named pocket.txt... exit 0;
See 14.13 Content-Length and 14.25 If-Modified-Since for the gory details of what's going on under the hood.

Cheers!

Jim

Replies are listed 'Best First'.
Re^2: Perl on Windows XP needs to grab internet txt file.
by kansaschuck (Sexton) on Feb 03, 2008 at 15:35 UTC
    Thanks all! I went with the LWP Perl modules to access remote files. And that worked very well. ' thanks, kc

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://665777]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2023-09-27 05:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?