skiboy has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, The problem is I can only use Perl from a Win2K OS and the LWP::UserAgent module is for a Unix OS. Is there a module I can use for Windows OS? Or is there a way to download a file from a website using Perl for windows or another module?
  • Comment on Need a way to download a file from a web site.

Replies are listed 'Best First'.
Re: Need a way to download a file from a web site.
by ikegami (Patriarch) on Oct 25, 2004 at 18:22 UTC

    The LWP library (including the LWP::UserAgent module) is not just for unix. It works great in Windows, and I think it's even part of the core distribution. (It has definitely been included with ActivePerl for quite some time).

    There's also WWW::Mechanize (but it uses LWP).

    Update: Here's a simple example which uses LWP::UserAgent:

    use LWP; my $ua = LWP::UserAgent->new(); my $request = HTTP::Request->new('GET', 'http://www.perlmonks.org/'); my $response = $ua->request($request); die("...") unless ($response->is_success()); print($response->content());
Re: Need a way to download a file from a web site.
by Corion (Patriarch) on Oct 25, 2004 at 18:22 UTC

    I use LWP and LWP::UserAgent without problems under Windows - maybe you can tell us where exactly the problems lie you have with LWP::UserAgent?

    For me, LWP::UserAgent nicely installs via

    perl -MCPAN -e "install 'LWP::UserAgent'"
      Thanks this worked flawlessly as you said.
Re: Need a way to download a file from a web site.
by pg (Canon) on Oct 25, 2004 at 18:48 UTC

    Why is LWP::UserAgent only for UNIX, not for Windows, is there a different HTTP standard for Windows ;-?

    It works for both platforms! LWP::UserAgent does nothing more than form HTTP request, sending out, and get response back, parsing it.

      is there a different HTTP standard for Windows ;-?

      HTTP is a protocol that is OS independant. If there were issues with a given protocol on a given OS that would more refer to the implementation for that OS, but LWP is not one of them...as you point out.

      Regards Paul
Re: Need a way to download a file from a web site.
by shenme (Priest) on Oct 26, 2004 at 04:39 UTC
    Peek in your \Perl\bin directory. There's a GET.bat and a lwp-download.bat Try them out to satisfy yourself (without writing any code!) that LWP works fine on Win2K.