W::M is basically LWP::UserAgent. so you can also refer to perldoc lwpcook the 'large documents' section.
LARGE DOCUMENTS
    If the document you want to fetch is too large to be kept in memory,
    then you have two alternatives. You can instruct the library to write
    the document content to a file (second $ua->request() argument is a file
    name):

      use LWP::UserAgent;
      $ua = LWP::UserAgent->new;

      my $req = HTTP::Request->new(GET =>
                    'http://www.linpro.no/lwp/libwww-perl-5.46.tar.gz');
      $res = $ua->request($req, "libwww-perl.tar.gz");
      if ($res->is_success) {
         print "ok\n";
      }
      else {
         print $res->status_line, "\n";
      }

    Or you can process the document as it arrives (second $ua->request()
    argument is a code reference):

      use LWP::UserAgent;
      $ua = LWP::UserAgent->new;
      $URL = 'ftp://ftp.unit.no/pub/rfc/rfc-index.txt';

      my $expected_length;
      my $bytes_received = 0;
      my $res =
         $ua->request(HTTP::Request->new(GET => $URL),
                   sub {
                       my($chunk, $res) = @_;
                       $bytes_received += length($chunk);
                       unless (defined $expected_length) {
                          $expected_length = $res->content_length || 0;
                       }
                       if ($expected_length) {
                            printf STDERR "%d%% - ",
                                      100 * $bytes_received / $expected_length;
                       }
                       print STDERR "$bytes_received bytes received\n";

                       # XXX Should really do something with the chunk itself
                       # print $chunk;
                   });
       print $res->status_line, "\n";

In reply to Re^2: WWW:Mechanize click_button stream to file? by Qiang
in thread WWW:Mechanize click_button stream to file? by cormanaz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.