in reply to declare string with addition of two variables
If you can answer "what are you trying to achieve", we may be able to answer your question. If you are simply declaring two initialised variables then:
my $x = "Expected value is"; my $y = 2;
is the way to do it. However I'd expect $y would cause trouble in your code in that case - you do include use strict; in your script don't you?
If you are trying to increment $y and concatenate the result on to the end of the string then you need something like:
my $x = "Expected value is " . ($y + 2);
Note that the () are required.
|
|---|