Hi,
------ CODE ------
use strict;
use warnings;
use WWW::Mechanize;
use File::Basename;
use Number::Bytes::Human qw(format_bytes);
# CODE GOES ON HERE TILL
open( my $file2write, '>', "$base" );
binmode $file2write;
my $b;
$wmc->get(
"$link",
':content_cb' => sub {
my ($c, $r) = @_; # what are $c and $r ????
$b += length($c);
if ($r->content_length) {
printf STDERR "${base}${extension} -> %.2f%% : %s of %s \r",
100. * $b / $r->content_length,
format_bytes($b),
format_bytes($r->content_length);
}
print $file2write $c;
});
$b = 0;
print "\n";
close $file2write;
------ END ------
I got this snippet on perlmonks. It's a kind of progress bar. I want to know
what is being passed to @_ by ':content_cb' ??
my ($c, $r) = @_;
what are $c and $r?
Thread Next