open my $tailf, "tail -f $logFile |" or die; while (<$tailf>) { chomp; my $line = $_; if($line =~ m/ on $ipaddress/) { if (scalar(@matches) <= 2){ push(@matches, $line); } else { exit(0); } foreach $line (@matches){ print "$line\n"; } } }
The problem is I should be getting 2 lines but instead I get 6 lines? Any ideas what I'm doing wrong? to run it: ./script string
In reply to Array size issue by hmb104
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |