#!/usr/bin/perl -wT use strict; my $txt = '$a @b $c %d'; my $out1 = quotemeta($txt); (my $out2 = $txt) =~ s/([\$\@])/\\$1/g; print "txt = $txt\n"; print "out1 = $out1\n"; print "out2 = $out2\n"; =OUTPUT txt = $a @b $c %d out1 = \$a\ \@b\ \$c\ \%d out2 = \$a \@b \$c %d
-Blake
In reply to Re: How can I replace special characters?
by blakem
in thread How can I replace special characters?
by derwitzbold
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |