local $/ = "find this string"; while () { if ( chomp ) { # you know you found an occurrence } }