well, no, I'm not checking.  But it is open correctly because I use it
earlier in the script and it never gets closed until the very end.


On Fri, 10 Aug 2001 09:22:11 -0500
Mooney Christophe-CMOONEY1 <[EMAIL PROTECTED]> wrote:

> if $#scans==-1, then the array is empty (of course!)
> 
> Are you checking to make sure LOGFILE opened correctly?
> 
> -----Original Message-----
> From: Tyler Longren [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 10, 2001 9:19 AM
> To: Perl-Beginners
> Subject: number of elements in array is -1?
> 
> 
> Hello everyone,
> 
> I have a problem.  I just want to print the number of elements in an
> array.  Here's the code:
> my @scans;
> my $last_host = "192.168.1.1";
> while (<LOGFILE>) {
>       push (@scans, $_)
>       if m/$last_host/i;
> }
> 
> shouldn't that put all of the results into the @scans array?  I know
> there'd just be a bunch of the same value.  
> $array[0] would equal 192.168.1.1
> and $array[1] would equal 192.168.1.1
> 
> I try to show the number of elements in the array like so:
> print "$#scans";
> 
> But that prints "-1".  I know for a fact there are at least 2 entries in
> LOGFILE that have an IP of 192.168.1.1.
> 
> Thanks,
> Tyler Longren
> Captain Jack Communications
> [EMAIL PROTECTED]
> www.captainjack.com
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to