use LWP::Simple; use strict; my ($count, $max, $URL); unless (defined ($URL = shift)) { print "\n\nEnter the site address which you would like to access: "; chomp($URL = ); } $URL = "http://" . "$URL"; print "Site address is $URL \n"; unless (defined ($max = shift)) { print "Enter the number of times to hit the site: "; chomp($max = ); } for ($count = 0; $count <= $max; $count++){ my $content; unless (defined ($content = get $URL)) { die "could not get $URL\n"; } if ($content =~ /Test1/i) { print "."; } elsif ($content =~ /Test2/i) { print "Fetched page from Server2 \n"; $count++; &result; } else { print "Page not retreived \n" } } sub result { print "page retrieved after $count tries \n"; exit; }