Try this version of your first snippet, to understand almut's first point a little better:
#!/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";
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 use strict; use warnings; print "Contents of ARGV:\n>=", join( "=<\n>=", @ARGV), "=<\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.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.