my ($status, $content, $type, $base, $length) = get_page($site); print $length, " bytes\n"; #################################################### sub get_page { my ($site, $pi) = @_; $browser = LWP::UserAgent->new() unless $browser; my $response = $browser->get($site); my $status = $response->status_line; my $content = $response->content; my $type = $response->content_type; my $base = $response->base; my $length = commify(length($content)); if (!$response->is_success) { die "\nError: $status ($site)\n"; } return $status, $content, $type, $base, $length; } #### my %pi; @%pi{qw(status content type base length)) = get_page($site); print $length, " bytes\n"; #################################################### sub get_page { my ($site) = @_; $browser = LWP::UserAgent->new() unless $browser; my $response = $browser->get($site); if (!$response->is_success) { die "\nError: $status ($site)\n"; } return $response->status_line, $response->content, $response->content_type, $response->base, commify(length($content)); } #### my %pi; get_page($site, \%pi); print $pi{'length'}, " bytes\n"; #################################################### sub get_page { my ($site, $pi) = @_; $browser = LWP::UserAgent->new() unless $browser; my $response = $browser->get($site); $pi->{status} = $response->status_line; $pi->{content} = $response->content; $pi->{type} = $response->content_type; $pi->{base} = $response->base; $pi->{length} = commify(length($pi->{content})); if (!$response->is_success) { die "\nError: $status ($site)\n"; } } #### my %pi; get_page($site, \%pi); print $pi{'length'}, " bytes\n"; #################################################### sub get_page { my ($site, $pi) = @_; $browser = LWP::UserAgent->new() unless $browser; my $response = $browser->get($site); if (!$response->is_success) { die "\nError: $status ($site)\n"; } my $content = $response->content; @{$pi}{qw(status content type base length)} = ( $response->status_line; $content; $response->content_type; $response->base; commify(length($content)); ); return; }