in reply to Array size issue

You don't want to exit(0). You want to break out of the loop with last. Then, after the loop, not within it, you want to output your results.

Take some lines of the source file and walk through a printout of the code, using your fingertips. Ask yourself the questions that you ask the computer to make, and do what you have told the computer to do in response to them. The flaws in your present design will quickly become clear to you as they will best with no other way.

Replies are listed 'Best First'.
Re^2: Array size issue
by hmb104 (Sexton) on Oct 15, 2012 at 17:35 UTC

    This is what I got from your reply, but still not working, this time I get nothing:

    while (<$tailf>) { chomp; my $line = $_; if($line =~ m/ on $ipaddress/) { if (scalar(@matches) <= 3){ push(@matches, $line); } } last; } foreach $line (@matches){ print "$line\n"; }
Re^2: Array size issue
by hmb104 (Sexton) on Oct 15, 2012 at 17:29 UTC

    Which loop are you talking about? foreach? Or do you mean the if conditions?