in reply to Re: Re: Re: Re: While count ---don't see it
in thread While count ---don't see it

When you check an array in a scalar context, you get the number of elements in the array. When you check $#, you get the highest subscript, which is one less than the number of elements since the array is zero-based. So, you would want to add one, not subtract.

Also, the while loop also promises not to alter $count if $count is already higher than the number of elements in @processlist. So, I believe you would need this:

$count = @processlist unless ( $count > @processlist ); ## Or $count = $#processlist + 1 unless ( $count > ($#processlist + 1));