$ perl -E 'my $x = "2}"; "ab" =~ /.{$x/ and say "Matched"' Matched