Re: How to pass string in command line argument.
- From: mumia.w.18.spam+nospam@xxxxxxxxxxxxx (Mumia W.)
- Date: Thu, 26 Oct 2006 09:03:45 -0500
On 10/26/2006 05:47 AM, perl pra wrote:
hi ,
I want to pass a command argument to perl script with double quotes (" );
below is my scenario
my xml file is something like this ..
<root>
<reff>
<var1>123</var1>
<var2>this is my name</var2>
</reff>
<reff>
<var1>234</var1>
<var2>this is others name </var2>
</reff>
</root>
my perl script is something like this
my $xmlfile = "./samp1.xml";
my $ref = eval { XMLin($xmlfile) };
if ($@){
print "XML Read ERROR";
} else {
foreach my $item (@{$ref->{reff}}) {
system("perl C:\\Document and settings\\Desktop\\search.pl -n
\"$item->{var2}\"");
the search.pl file consists of .
print "AGRV[1]";
my out put is
this is my name
this is others name
i understand that the string is getting passed to the perl script with out
quotes ..
just a straight string is geeting passed (like this this is my name)
but i need to send the entire string including double quotes to the
script.,something like this ( "this is my name")
Waiting for your solutions....
thanks in advance
perl guy
Under Linux, you could separate the arguments in the system() call, like so:
system('perl','C:\\Document and settings\\Desktop\\search.pl',
'-n', '"' . $item->{var2} . '"');
Obviously, you're not running under Linux, so try this:
system(qq{perl "C:\\Documents and Settings\\Desktop\\search.pl" -n "\\"$item->{var2}\\""});
I'm unsure of how many backslashes you need to escape those quotes.
.
- Follow-Ups:
- Re: How to pass string in command line argument.
- From: Perl Pra
- Re: How to pass string in command line argument.
- References:
- How to pass string in command line argument.
- From: Perl Pra
- How to pass string in command line argument.
- Prev by Date: Re: Sample https:// login script
- Next by Date: Help regarding strings
- Previous by thread: Re: How to pass string in command line argument.
- Next by thread: Re: How to pass string in command line argument.
- Index(es):
Relevant Pages
|