local $/ = "the string to match"; while () { #do stuff with the "line" in $_ #chomp will remove "the string to match"; }