Appy16 has asked for the wisdom of the Perl Monks concerning the following question:

I am working on a script Which pings a URL and then mails the status if a failure is encountered. The script copies URLs from a text file, pings them and mails the status. For running the script every hour i am using cron.

The file contains many URLs but i need to check only those which contain PIng before them.eg

Test File2:

Ping google.com

Ping yahoo.com

abcd.com

hello.com

Here only google.com and yahoo.com should be checked and others should not. I am trying to check the URLs containing Ping by compairing them as under but i recieve the following error :

Can't find Unicode property definition "i" at test12.pl line 21, <$fh> line 6.

What does this error mean and What am I doing wrong?? Kindly Help. Thanx in advance.
#!/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 = "appy.test1\@gmail.com"; my $subject = "URLs not responding."; tie @file, 'Tie::File', $testfolder . "testfile2.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 ) { print "$URL\n"; my $alive = ping(host => "$URL"); if ($alive) { print "$URL is active.\n"; } else { print "$URL is inactive\n";my $email = Email::MIME->create( header => [ From => $from, To => $to, Subject => $subject, ], body => "$URL is not working" ); my $sender = Email::Send->new( { mailer => 'Gmail', mailer_args => [ username => 'test12@gmail.com', password => '1234qwerty', ] } ); eval { $sender->send($email) }; die "Error sending email: $@" if $@ } } }

Replies are listed 'Best First'.
Re: Can't find Unicode property definition
by Corion (Patriarch) on Mar 23, 2010 at 08:54 UTC

    Have you looked at line 21?

    \Ping

    This does not make sense. Maybe you meant ping? Read perlre about what \P means.

      Well I tried that and it worked. Thanx alot. But now I have another problem.
      my $alive = ping(host => "$URL");
      In the above statement the $URL now refers to ping google.com instead of  google.com. How do I correct that??
        By removing the leading "ping " with substr, split or a regex/subsitution
        Perl 6 - links to (nearly) everything that is Perl 6.
        s/^ping\s+//; is one way. Changes the string, but I think that's not a problem as you have things.
Re: Can't find Unicode property definition
by Anonymous Monk on Mar 23, 2010 at 09:34 UTC
    use diagnostics, or splain to see expanded error message.
    Can't find Unicode property definition "i" at test12.pl line 21, <$fh> line 6 (#1)
    (F) You may have tried to use \p which means a Unicode property (for example \p{Lu} is all uppercase letters). If you did mean to use a Unicode property, see perlunicode for the list of known properties. If you didn't mean to use a Unicode property, escape the \p, either by \\p (just the \p) or by \Q\p (the rest of the string, until possible \E).