# change: print $buffer[0] if /$pat/; # to: print $buffer[0] if /\Q$pat\E/o;