Perl Script Problem

Felipe Figueiredo philsf79 at gmail.com
Thu Nov 15 11:58:25 UTC 2007


A Thursday 15 November 2007 08:47:28, Anton Hofmann escreveu:
> Hi,
> 
> hope some perl gurus read that.
> 
> i have a problem with a small prerl query.
> 
> 
> if ($error eq "0") {
> 	system ("/vmbackup/send.sh -u Backup complete.");
> 	}
> if ($error gt "0" and $error le "999") {
> 	system ("/vmbackup/send.sh -u Backup error");
> 	}
> if ($error gt "1000") {
> 	system ("/vmbackup/send.sh -u Backup error, snapshot available");

[...]
 
> I dont understand why if ($error gt "0" and $error le "999") grap to.
> This query should just send a mail if the value in the txt file is
> between 0 and 999.

Try using parenthesis in each test
( ($error >= "0") and ($error <= "999") )

also, why are you using string comparison operators (gt, le, eq...) for 
integers? using <=, == and >= is more indicated (and prevents warnings when 
you use -w, warnings and strict).




More information about the ubuntu-users mailing list