while ( <> ) { last if m/perl/i; } print "There were $. lines until I found perl\n";