You'll see that your use of s/// didn't really change anything. So when you face a problem like this, it's good to print both the "before" and the "after". In terms of handling command line args from @ARGV, you might want to try some tests first with a script like this:#!/usr/bin/perl -w use strict; # replacing double back slash... my $string1 = "-----\\---------"; print "The starting value is: $string1\n"; # add this line $string1 =~ s/"\\"/"\"/g; print "The resulting value is: $string1\n";
Run that a few times with different patterns of interest as command-line args, and see what happens. It's really just a way of finding out what the shell is doing to the args before passing them on to the perl script, which is a useful thing to know. Then add some s/// operations to alter the args, and see how those work.#!/usr/bin/perl use strict; use warnings; print "Contents of ARGV:\n>=", join( "=<\n>=", @ARGV), "=<\n";
In reply to Re: How can I CORRECTLY pass strings as arguments from command line?
by graff
in thread How can I CORRECTLY pass strings as arguments from command line?
by Zygor1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |