Re: How to pass string in command line argument.
- From: mumia.w.18.spam+nospam@xxxxxxxxxxxxx (Mumia W.)
- Date: Sat, 28 Oct 2006 19:38:25 -0500
On 10/28/2006 01:52 AM, perl pra wrote:
On 10/26/06, Mumia W. <mumia.w.18.spam+nospam@xxxxxxxxxxxxx> wrote:I tried this but no luck..
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.
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 .)
Did you see the double backslashes I had in my program?
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
Perl Pra, please bottom-post your replies. When you reply, place your reply below the quoted text. This makes technical conversations more logical.
On my Linux system, this program prints «"Hi there"» :
if (@ARGV < 1) {
system (qq{$0 "\\"Hi there\\""});
} else {
print $_, "\n" for (@ARGV);
}
.
- 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: Analize Java source file with perl?
- Next by Date: Re: match data based on matching field
- Previous by thread: Re: How to pass string in command line argument.
- Next by thread: Perl and Cookies
- Index(es):
Relevant Pages
|