$file =; chomp($file); if (m/(\d+)\|\Q$file\E$/x) { do something} but if match (/^aaa\[/) {die};