If you want to include a variable inside a regex, but don't want the data in the variable treated as part of the regex then you wrap it in \Q \E (which i beleve stand for quote and end, its at least how i rememebr)
#!/usr/bin/perl use strict; use warnings; my $char = '\\'; my $str = 'bla'; $str =~ s/\Q$char\E?$/$char/; print "$str\n";
In reply to Re: Appending backslash to a string
by eric256
in thread Appending backslash to a string
by garu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |