open my $tailf, "tail -f $logFile |" or die; for (1,2) { my $line = ''; $line = <$tailf> until $line =~ / on $ipaddress/; push @matches, $line; }