#!/usr/bin/perl use warnings; use strict; use LWP; my $browser = LWP::UserAgent->new(); my $response = $browser->get('http://www.perl.com/images/tabs/tab-perlblk.gif', ':content_cb' => \&hex_dump, ':read_size_hint' => 123, ); print "Waiting a bit...\n"; sleep 10; my $age = $response->current_age(); print "$age\n"; # debug my $days = int($age/86400); $age -= $days * 86400; my $hours = int($age/3600); $age -= $hours * 3600; my $mins = int($age/60); $age -= $mins * 60; my $secs = $age; print "The document is $days days, $hours hours, $mins minutes, and $secs seconds old.\n"; sub hex_dump { my ($data, $response) = @_; print length($data), " bytes:\n"; print ' ', unpack('H*', substr($data,0,16,'')), "\n" while length $data; return; }