On Tue, Nov 11, 2008 at 11:38, JC Janos <[EMAIL PROTECTED]> wrote:
> I stumbled on an answer.  Adding "2>&1" apparently works, i.e.,
>
>  $result = `2>&1 $WGET $file`;
>
> Not sure if it's the only/best way.
snip

Well, the best way would be to use LWP*, LWP::Simple**, or
WWW::Mechanize*** to allow Perl to get the data without resorting to
an external program:

#!/usr/bin/perl

use strict;
use warnings;

use LWP::Simple;
use File::Basename;

my $url  = "http://wonkden.net/resume.pdf";;
my $file = basename $url;

my $status = mirror($url, $file);

if ($status == RC_OK) {
        print "got file\n";
} elsif ($status == RC_NOT_MODIFIED) {
        print "didn't need to get the file\n";
} else {
        print "got error $status\n";
}

* http://search.cpan.org/dist/libwww-perl/lib/LWP.pm
** http://search.cpan.org/dist/libwww-perl/lib/LWP/Simple.pm
*** http://search.cpan.org/dist/WWW-Mechanize/lib/WWW/Mechanize.pm

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to