Example usages:
Without quotemeta, the following would not match. It would try (and fail) to match a digit.
$not_a_regexp = '\\d'; # The 2 chars: \d $not_a_regexp_quoted = quotemeta($not_a_regexp); # The 3 chars: \\d $not_a_regexp =~ /^$not_a_regexp_quoted\z/; # Matches.
Without quotemeta, eval would try to execute '''., which is invalid Perl.
$not_code = "'"; # ' $not_code_quoted = quotemeta($not_code); # \' $string = eval "'$not_code'"; # '
In reply to Re: QuoteMeta in perl
by ikegami
in thread QuoteMeta in perl
by qsl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |