use strict; use warnings; use 5.010; my $string= 'my_stuff[1]=400'; my $pattern = 'my_stuff\[1]='; say "They match." if $string =~ /$pattern/; --output:-- They match.