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}");