Mar 16, 2009, 10:44 AM
Post #2 of 3
You never initialize $mystring in your code snippet. Consequently,
Will always fail. Not sure why you want the backslashes, but this:
$mystring =~ s/$mytest1/$myrep1/g;
my $mytest1 = "\\\\abc"; # escape backslash twice: Once for the definition and once for the regex.
my $myrep1 = "@\\abc"; # escape backslash once for the regex.
my $mystring = "some string containing \\abc \\abc a couple of times"; # escape backslash once for the definition.
$mystring = ~s/$mytest1/$myrep1/g;
Which is what you say you want. If not, it would help if you told us what these strings are and what they're for.
some string containing @\abc @\abc a couple of times