use 5.010; use strict; use warnings; use LWP; my $agent = LWP::UserAgent->new(); my $response = $agent->get('http://example.com/foo/bar'); if ($response->is_success) { for my $chunk ($response->decoded_content(charset => 'none') =~ m/.{794}/g) { # ... process $chunk of binary data ... } } else { die 'Network protocol error: ' . $response->status_line; }