Perl LWP callback function

I'm using a callback function when downloading a file.  The request is a url that actually calls a server side script that is responsible for zipping up the contents to create the zip file that can be downloaded.  So I don't know the size of the file.

The current code will print "." characters while it's downloading.  However, it seems to print a line of about 100 "." characters at a time and ends up filling the entire screen full of these characters by the time the file is downloaded.  I would expect the zip file that is being downloaded to usually be around 300MB.

How can I limit this display so there are not so many "." chars?


  my $response = $ua->request($request, \&callback,1024**3);
sub callback {
   my ($data, $response, $protocol) = @_;
   print $out $data;
   print ".";

Open in new window

mock5cAsked:
Who is Participating?
 
ozoCommented:
our $count;
sub callback {
   my ($data, $response, $protocol) = @_;
   print $out $data;
  my $p=$|;  
   $|=1;
   print "." unless ++%count %10;
   print "\n" unless $count %500;
   $|=$p;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.