in reply to Re^2: Using . in variable name
in thread Using . in variable name

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

Replies are listed 'Best First'.
Re^4: Using . in variable name
by bitingduck (Deacon) on Apr 17, 2015 at 07:24 UTC

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

    system("myotherscript $app1.svr=3 $somevar=27");
      Double quotes interpolate variables. This would therefore replace $app1 with the contents of the $app1 variable.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^4: Using . in variable name
by manpreet333 (Initiate) on Apr 17, 2015 at 09:03 UTC

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

      You can call the variable anything. Let's say $dog or $cat in which case:

      my $dog = 'http://www.perl.org/'; my $cat = 'https://metacpan.org/'; system("ant -file japi/test.xml -Dapp1.url=$dog -Dapp2.url=$cat");

      Which is equivalent then to this command you would type at your prompt:

      ant -file japi/test.xml -Dapp1.url=http://www.perl.org/ -Dapp2.url=htt +ps://metacpan.org/

        shell is danger :) system 'ant', '--file', 'japi/test.xml', "-Dapp1.url=$dog", "-Dapp2.url=$cat";

      Maybe you don't want to use a variable here but a hash with the appropriate keys?

      Or just change ${app1.url} to $app1_url if you feel uncomfortable with hashes?