littlemonk has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I am new to this Forum. Below is my perl script:

use strict; use warnings; print "First Argument: $ARGV[0]"; print "\n********************\n"; print "Second Argument: $ARGV[1]";
and i save the code in a file test.pl When I execute this with arguments perl test.pl "D:\First Folder\test\" "D:\Second Folder" The Output shown was: First Argument: D:\First Folder\test" D:\Second ******************** Second Argument: Folder The Output what I expect is: First Argument: D:\First Folder\test ******************** Second Argument: D:\Second Folder Is there any idea to get the output what i expect, without changing Backward slashes to Forward slashes or Deleting the Final slash in First argument Thanks in Advance

Replies are listed 'Best First'.
Re: Command line
by Marshall (Canon) on Aug 08, 2011 at 10:28 UTC
    Windows thinks that the trailing \" means an escaped version of " and doesn't see it as a normal " which would end the argument's quoting. So you need one more \ if you want to end the first arg with a \ character.
    perl test.pl "D:\First Folder\test\\" "D:\Second Folder"

    This is a Windows shell thing and there is really nothing that Perl can do about it.

Re: Command line
by Utilitarian (Vicar) on Aug 08, 2011 at 10:14 UTC
    Welcome to the forum, please use <code> tags around your code and data as it makes it legible (You had to preview this post to send it, how did you miss that it was mangled?)
    Is there a space between the two arguments on the command line? if not you would see what you have described

    UpdateThough escaping the quote forces this as Marshall describes below.

    print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."