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:
Expand|Select|Wrap|Line Numbers
- #!/usr/bin/perl -w
- use strict;
- # replacing double back slash...
- my $string1 = "-----\\---------";
- $string1 =~ s/"\\"/"\"/g;
- print "The resulting value is : $string1 \n";
This of course works:
Expand|Select|Wrap|Line Numbers
- C:\>
- C:\>test_string_replace21.pl
- The resulting value is : -----\---------
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:
Expand|Select|Wrap|Line Numbers
- #!/usr/bin/perl -w
- use strict;
- my $string1 = $ARGV[0];
- $string1 =~ s/"\\"/"\"/g;
- print "The resulting value is : $string1 \n";
Expand|Select|Wrap|Line Numbers
- C:\>test_string_replace2.pl "-----\\-----"
- The resulting value is : -----\\-----
Thanks to anyone who can help.