Re: How to pass string in command line argument.



perl pra wrote:
>
> Rob Dixon wrote:
>>
>> perl pra wrote:
>>>
>>>
>>> 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")
>>
>> Why are you shelling out to another Perl process just to print a value
>> from a
>> hash? As far as I can tell your loop should look like this:
>>
>> foreach my $item (@{$ref->{reff}}) {
>> print qq("$item->{var2}"\n);
>> }
>
> ------- thats just example i gave actually i have to search for the
> string with quote included in the string.
>
> I am clueless abt the solution as i am beginner.
>
> waiting for some suggestion or solution.

(Please keep your posts on the beginners list so that others can help me to help
you, and also benefit from the solution to your problem. Thanks.)

Please tell us exactly what it is you need to do. Shelling into Perl from
Perl is almost certainly the wrong way to go about it, but It's not at all clear
what end result you need.

What I can suggest is this:

perl -e "print $ARGV[0], qq(\n)" "\"xxx\""

but I have the horrible feeling I'm helping you to create something very ugly!

Let us know the full details please,

Rob
.



Relevant Pages

  • Cant Compiling perl5.8.8 on FreeBSD6.2
    ... WITH_DEBUGGING=yes Build perl with debugging support. ... First let's make sure your kit is complete. ... What is the file extension used for shared libraries? ... I'll use sprintf to convert floats into a string. ...
    (comp.unix.bsd.freebsd.misc)
  • Re: use of DBI; I am getting multiple error messages mixed in with ?the correct output.
    ... But I'm not talking about C++ or Java or SQL. ... This is a perl newsgroup. ... to means by a "defined null string", as opposed to an undefined value. ... And where exactly are you getting the idea that the empty string is a ...
    (comp.lang.perl.misc)
  • Re: Perl Strings vs FileHandle
    ... Just wanted to run this through Perl gurus to see if fit is ... testing it every time through the loop. ... The comparison test to the string '1' is superfluous. ... Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers ...
    (comp.lang.perl.misc)
  • Re: Perl ActiveX: A VBA string passed to my control is treated as a doubel-quoted string
    ... I have written a Perl ActiveX control that's suppose to do some regular ... When I use this string in VBA, I get erroneous resutls from my control. ... Perl regex has its own set of escape characters like any other parser. ...
    (comp.lang.perl.misc)
  • Re: How to get "perl -V"s output programmatically?
    ... JB> Sometimes I agree with her regexp-less solutions. ... Sadly I miss some of the Perl fun, ... especially not for contains literal string ... sure you can do many string things without regexes, ...
    (comp.lang.perl.misc)