$ perl -Mstrict -wE 'my $str = "foobar"; say 1 if $str =~ /[o]{,2}/' Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/[o]{ <-- HERE ,2}/ at -e line 1.