Smith, Derek wrote:
: Charles K. Clarkson wrote:
:
: : It seems that when the test on line 64 is true, $arry[0]
: : is not defined (and not initialized) and throws this error.
:
: I thought that was the problem initially but tested it and I do
: see this element populated on lines 64 and 65
:
: 61 for (;<PS>;) {
: 62 push @arry, (split)[1];
: 63 }
: 64 print $arry[0],"\n";
: 65 print scalar @arry,"\n";
: 66
: 67 if (scalar defined @arry < 1) {
: 68 print LOG "named was not running, now restartng\n", dateme();
: 69 system ("echo named dubdns02|mailx -s named $oncall");
: 70 system ("/sbin/init.d/named start");
: 71 }
: 72 print $arry[0],"\n";
: 73
: 74 open (PSO, "ps -p$arry[0] -o vsz |") or die "unable to spawn ps -p $!";
:
: __OUTPUT__
:
: 7431 is the PID.
:
: csdns03# perl named_monit.pl
: 7431
: 1
: 7431
Did line 74 throw the uninitialized warning in this case?
The original line 64 (now line 67) simply tested "@arry < 1".
Such an array would have no elements in it. $arry[0] would have no
value in it. If line 64 tested false, as in this case, then the
warning should not have appeared. Something like this might avoid
the error.
if ( @arry < 1 ) {
print LOG "named was not running, now restartng\n", dateme();
system ("echo named dubdns02|mailx -s named $oncall");
system ("/sbin/init.d/named start");
} else {
local *PSO;
open PSO, "ps -p$arry[0] -o vsz |" or die "unable to spawn ps -p
$!";
while (<PSO>) {
next if /\D/;
exit 1 if $_ < VSZ;
print LOG "named vsz reached over 60mb, now stopping &
starting\n";
print LOG dateme(), "\n";
namedchk();
}
close PSO;
}
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
Free Market Advocate
Web Programmer
254 968-8328
Don't tread on my bandwidth. Trim your posts.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>