while () { if ( $_ =~ /(Some pattern)/i ) { print("- $1 encountered"); last; } } close PIPE;