Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Using . in variable name

by bitingduck (Chaplain)
on Apr 17, 2015 at 07:04 UTC ( [id://1123701]=note: print w/replies, xml ) Need Help??


in reply to Using . in variable name

Can you show some code and explain how you're going to access the variable from another script? Generally things get passed around between scripts and programs in such a way that it doesn't much matter to one program what it's called internally in another one.

Replies are listed 'Best First'.
Re^2: Using . in variable name
by manpreet333 (Initiate) on Apr 17, 2015 at 07:08 UTC

    Thanks everyone for the quick responses but that's the thing, I do not have access to the script. I have just been asked to pass it as $app1.svr which I am not able to do from Perl.

    If this doesn't work out, I will have to rewrite my code in another language, which I am hesitating to do.

    Anyways, as you mentioned, it's not possible so I might as well start exploring other options.

      Maybe I didn't understand the problem as you stated it.

      Can you maybe take a step back and tell us the problem you're trying to solve? If you're calling another script, that script is likely invoked via system or exec. Maybe you don't want to use a variable name but a variable value?

      You can append a value to a string by using dot itself, or by using double quotes:

      print "$app.svr\n"; print $app . ".svr\n";

        Or a parameter name, e.g. (for the OP):

        system("myotherscript $app1.svr=3 $somevar=27");

        Thank you for all the help again. Here's the code that invokes the script:

        system("ant -file japi/test.xml -Dapp1.url=${app1.url} -Dapp2.url=${app2.url}");

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1123701]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-24 06:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found