package Foo::Webtest; use strict; use warnings; use URI; use Hook::LexWrap; use WWW::Mechanize; use Class::MethodMaker ( new => 'new', object => [ 'WWW::Mechanize' => { slot => 'browser', comp_mthds => [qw/ add_header agent_alias back base click content ct current_form field find_all_links find_link follow_link form_name form_number forms get is_html links quiet redirect_ok reload request response set_fields status submit submit_form success tick title untick uri /], } ]); my $start_time; my @times; my %URI; if ($ENV{TRACK_NAVIGATION}) { foreach my $method (qw/back click follow_link get reload submit submit_form/) { wrap $method, pre => sub {$start_time = time}, post => sub { my $end_time = time; my $time = $end_time - $start_time; push @times => $time; push @{$URI{$_[0]->base_uri}} => $time; } } } #### my $webtest = Foo::Webtest->new; $webtest->get($page_to_test); # and then use the code in my root post