use LWP::UserAgent; sub little_bit { my ( $content, $response, $protocol ) = @_; printf "chunk length %d\n", length $content; if ( $content =~ /the/i ) { print "chunk with the 'the': $content\n"; die; } } my $ua = LWP::UserAgent->new(); my $response = $ua->get( 'http://perlmonks.org/', ':content_cb' => \&little_bit, ':read_size_hint' => 100 ); __END__ chunk length 100 chunk length 100 chunk length 100 chunk with the 'the': The Monastery Gates