in reply to Finding the second line an item appears on

This is a bit brute force, but I'm sure one of the other monks has a more elegant way...

my @matches; while (<FILE>) { push @matches, $_ if /formulae/; last if scalar @matches == 2; }

You'd be out of luck with this one, though, if 'formulae' could occur more than once per line and still have to stop.