Re: How to pass string in command line argument.
- From: "kens" <kenslaterpa@xxxxxxxxxxx>
- Date: 28 Oct 2006 05:33:51 -0700
Perl Pra wrote:
I tried this but no luck..
let me tell me explain my problem in detail to you guys so that you may
give me the apt solution.
i have perl script that searches given string (the string should be passed
in command line argument),
The string should be sent to the script with double quotes attached to it
.(if the string is sent to the script with quotes the spaces in the string
are taken as AND other wise the spaces are taken as OR)
I will write all these strings in xml file with quotes...
I have to retrive these strings and then send to the script ....
(i am sending the string to script something like this
system("perl C:\\Document and settings\\Desktop\\search.pl -n
\"$item->{var2}\"");
If i send the string as above the script is not taking the double quotes ..
it searches with the plain string (with out double quotes and produce the
wrong results .)
hope that explains the problem i have..
Is there any other way to solve the problem ...other than the way which i am
employing..
I am stuck up. please give me some solution.
Waiting for solutions..
Thanks in advance
Perl Pra
On 10/26/06, Mumia W. <mumia.w.18.spam+nospam@xxxxxxxxxxxxx> wrote:
On 10/26/2006 05:47 AM, perl pra wrote:
hi ,);
I want to pass a command argument to perl script with double quotes ("
out
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
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.
--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
<http://learn.perl.org/> <http://learn.perl.org/first-response>
------=_Part_63336_16565188.1162018376337--
Where is your code (make a small script - or scripts - in this case
that exhibits the problem you are having). You have been given two
solutions, have you tried those. I am running on a Windows machine and
at least one solution appears to work. For instance:
========== SCRIPT 1 =============
use strict;
use warnings;
my $item = "TEST QUOTES";
system(qq{p.pl "\\"$item\\""});
========== SCRIPT p.pl ============
use strict;
use warnings;
$a = shift;
print $a . "\n";
Ken
.
- References:
- How to pass string in command line argument.
- From: Perl Pra
- Re: How to pass string in command line argument.
- From: Mumia W.
- Re: How to pass string in command line argument.
- From: Perl Pra
- How to pass string in command line argument.
- Prev by Date: Re: How to pass string in command line argument.
- Next by Date: Re: How to pass string in command line argument.
- 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
|
|