#!/usr/bin/perl -- use strict; use warnings; use HTML::Tree; use WWW::SimpleRobot; Main( @ARGV ); exit( 0 ); sub Main { my @urls = @_; # or hardcode them here my $robot = WWW::SimpleRobot->new( URLS => \@urls, FOLLOW_REGEX => $FOLLOW, DEPTH => 2, TRAVERSAL => 'depth', VISIT_CALLBACK => \&Botulism, BROKEN_LINK_CALLBACK => \&Snicklefritz, ... ); eval { $robot->traverse; 1 } or warn "robot died, but we caught it: $@ "; } sub MAlt { ... } sub Botulism { my ( $url, $depth, $html, $links ) = @_; ...; no warnings 'uninitialized'; eval { my $Title = substr $tree->look_down( '_tag', 'title' )->as_text , 0, 65; print ...; } or do { my $Title; for my $tag( qw' h1 h2 h3 h4 p ' ){ last if eval { $Title = substr $tree->look_down( '_tag', $tag )->as_text , 0, 65; if( length $Title ){ $html->push_content($Title); print ...; } }; } unless($Title){ print ...; } } ...; summarize ... } sub Snicklefritz { my ( $url, $linked_from, $depth ) = @_; ...; } sub Ebola { my( $html, $clip, $text ) = @_; if(defined $text and length $text ) { $text = substr $text, 0, $clip; $html->push_content( $text ); } }