The problem is if I do this from within perl code directly it is no problem but when I attempt to pass a string from the command line, it seems to lose something in the translation and when I try to do the replace it does not work. So the question is HOW to pass the string from the command line so it works. Here is the sample code that works without passing from the command line:
perl source code = test_string_replace21.pl:
This of course works:Code: ( text ) #!/usr/bin/perl -w use strict; # replacing double back slash... my $string1 = "-----\\---------"; $string1 =~ s/"\\"/"\"/g; print "The resulting value is : $string1 \n";
As you can see, the double back slash is changed to a single one as expected. But now use the following code which should do the same thing as above but takes the string as argument from the command line: perl source code = test_string_replace2.pl:Code: ( text ) C:\> C:\>test_string_replace21.pl The resulting value is : -----\---------
I run it from DOS command line:Code: ( text ) #!/usr/bin/perl -w use strict; my $string1 = $ARGV[0]; $string1 =~ s/"\\"/"\"/g; print "The resulting value is : $string1 \n";
As you can see, the double back slash is still there!!!!! Why????? And how do I get around it?Code: ( text ) C:\>test_string_replace2.pl "-----\\-----" The resulting value is : -----\\-----
Thanks to anyone who can help.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |