Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 520633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:09:56+00:00 2026-05-13T08:09:56+00:00

I have the following code: $mech->get($someurl, :content_file => $i.flv); So I’m getting the contents

  • 0

I have the following code:

$mech->get($someurl, ":content_file" => "$i.flv");

So I’m getting the contents of a url and saving it as an flv file. I’d like to print out every second or so how much of the download is remaining. Is there any way to accomplish this in WWW::Mechanize?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:09:57+00:00Added an answer on May 13, 2026 at 8:09 am

    Many thanks to Peter Kovacs’ answer for leading me to the correct answer. It turned out to be a bit more elaborate than I’d expected though so I decided to (horror) answer my own question.

    As Peter showed, I can set a callback like so:

    $m->get($u, ":content_cb" => \&callback);
    

    But now I can’t save the content using the :content_file value, because I can only choose one of the two. The callback function gets passed the data, and I ended up writing that to a file instead.

    I also get a response object which contains the total size of the content as friedo pointed out. So by keeping a running total of content received so far and dividing it by the total content I can find out what percent of the content has been downloaded. Here’s the full callback function:

    open (VID,">$i.flv") or die "$!";
    $total = 0;
    sub callback
    {
        my( $data, $response, $proto ) = @_;
        print VID "$data"; # write data to file
        $total+= length($data);
        $size = $response->header('Content-Length');
        print floor(($total/$size)*100),"% downloaded\n"; # print percent downloaded
    }
    

    I hope that helps someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code: public abstract class Operand<T> { public T Value { get;
Have following code: public interface ITest { string St1 { get; } } public
I have following code to add values in drop down, values are getting added
We have following code in our out_logs controller for saving into two tables in
I have following code, after five tries (wrong words like dfasfasfb) the application stops.
I have following code: VAR1= ANOTHER_VAR=$VAR1/path/to/file ANOTHER_VAR_2=$VAR1/path/to/another/file ... # getopts which reads params from
I have following code and it returns false for @B LIKE @A comparison in
I have following code in the html file: <div class=navbar navbar-fixed-top> <div class=navbar-inner> <div
I have following code for initializing bean values depending upon url parameter. <f:metadata> <f:viewParam
I have following code: <div class='parent'> <div class='left-child'></div> <div class=right-child></div> </div> What I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.