#!/usr/bin/perl use warnings; use LWP::Simple; use Email::Send; use Email::Send::Gmail; use Email::MIME::Creator; use Net::Ping::External qw(ping); use Tie::File; my $testfolder = "/Users/Appy/Desktop/"; my $to = "test1\@gmail.com"; my $from = "test2\@gmail.com"; my $subject = "Uris not responding."; my $count = 1; tie @file, 'Tie::File', $testfolder . "testfile.txt" or die; foreach $URL (@file) { my $string1 = $URL; if ( $string1 =~ m/ # Match ping\s # 'ping ' /ix # i = Ignore case # x = allow the regexp to go over multiple lines ) { my $URI = substr $URL, 8; print "$URI\n"; sub myping { my $alive = ping(host => "$URI"); if ($alive) { print "$URI is active.\n"; } else { my $c = substr $URL, 5, 2; $count = $count + 1; if ($count <=round($c/2)) { &myping; } if ($count=$c) { ##create a log file } } }