in reply to Re: Help keep me from "shelling out" - download progress bar in cgi
in thread Help keep me from "shelling out" - download progress bar in cgi

Thanks! I am already using WWW::Mechanize. I would think my script would look funny if it had ...
use WWW::Mechanize; use LWP::Simple
... a minor point, but do you know of a way to get the $document_lenght using only WWW::Mechanize? Also I need to be able to "fork/background" the process that is carrying out the download and I also need to be able to query that process about the progress of the download. You have already be very helpful and I thank you for that. I hope it is not too much to ask if you can answer these additional questions.

Replies are listed 'Best First'.
Re^3: Help keep me from "shelling out" - download progress bar in cgi
by wfsp (Abbot) on Jun 15, 2009 at 06:26 UTC
    From the WWW::Mechanize docs:
    WWW::Mechanize is a proper subclass of LWP::UserAgent and you can also use any of LWP::UserAgent's methods.
    So
    use WWW::Mechanize;
    will do.
Re^3: Help keep me from "shelling out" - download progress bar in cgi
by CountZero (Bishop) on Jun 15, 2009 at 06:03 UTC
    I would think my script would look funny if it had ...
    use WWW::Mechanize; use LWP::Simple
    Nowhere, not even in "Perl Best Practices", is there any guideline that restrict you to a maximum number of modules you are allowed to use.

    Go ahead, the Perl Style Police will not come and arrest you!

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re^3: Help keep me from "shelling out" - download progress bar in cgi
by Anonymous Monk on Jun 15, 2009 at 06:42 UTC
    #!/usr/bin/perl -- use strict; use warnings; use WWW::Mechanize 1.54; my $ua = WWW::Mechanize->new; my $uri = URI->new('http://cpan.org/'); warn $ua->head($uri)->header('content-length'); warn $ua->res->header('content-length'); $ua->show_progress(1); $ua->get($uri); warn $ua->res->header('content-length'); warn $ua->title; #use DDS;warn Dump($ua); __END__
    5810 at test.pl line 10. 5810 at test.pl line 11. ** GET http://cpan.org/ ==> 13% 21% 46% 71%100%20 +0 OK 5810 at test.pl line 14. CPAN at test.pl line 15.
Re^3: Help keep me from "shelling out" - download progress bar in cgi
by jwkrahn (Abbot) on Jun 15, 2009 at 05:52 UTC

    Sorry, I've never used WWW::Mechanize and I don't know how to get the file size via this module.