Ahh...I just started wondering if it stopped at the end of the file...That
should fix it then.

Thank you everyone!!!!

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

> I thought so.  You read through the entire file, so by the time you get
> to
> your second while loop, you're at the very end of the file.  You need to
> rewind.
> 
> -----Original Message-----
> From: Tyler Longren [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 10, 2001 9:29 AM
> To: Brett W. McCoy
> Cc: [EMAIL PROTECTED]
> Subject: Re: number of elements in array is -1?
> 
> 
> I did:
> print "$scans[0]";
> and nothing is printed...where 192.168.1.1 SHOULD be printed...
> here's what I have:
> open (LOGFILE, $log_file) || die ("Could not open $log_file: $!");
> my @array;
> while (<LOGFILE>) {
>       chomp;
>       push (@array, $_)
>       if m/ida/i;
> }
> my $last_host = "192.168.1.1";
> my @scans;
> while (<LOGFILE>) {
>       push (@scans, $_)
>       if m/$last_host/i;
> }
> close(LOGFILE);
> print "$scans[0]";
> 
> 
> 
> On Fri, 10 Aug 2001 10:28:23 -0400 (EDT)
> "Brett W. McCoy" <[EMAIL PROTECTED]> wrote:
> 
> > On Fri, 10 Aug 2001, Tyler Longren wrote:
> > 
> > > I try to show the number of elements in the array like so:
> > > print "$#scans";
> > 
> > That actually gives the index of the last element, not the actual
> count
> > of elements.  You want:
> > 
> > print scalar(@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.
> > 
> > Did you dump the array to see if they are actually in there?
> > 
> > -- Brett
> >                                http://www.chapelperilous.net/btfwk/
> >
> ------------------------------------------------------------------------
> > Your conscience never stops you from doing anything.  It just stops
> you
> > from enjoying it.
> > 
> > 
> > -- 
> > 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]
> 

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

Reply via email to