while(<>) { tr/\r//d; # get rid of the CR print if /^\@QUERY/ .. /^\@ENDQUERY/; } #### while(<>) { tr/\r//d; print if /^\@QUERY/ .. eof; }