Solution

 78

There's a similar shorthand in Perl for this:

$a = 1;
print "@{[$a + 1]}"

This works because the [] creates a reference to an array containing one element (the result of the calculation), and then the @{} dereferences the array, which inside string interpolation prints each element of the array in sequence. Since there is only one, it just prints the one element.

2010-10-15

Solution

 10

You can use the @{[ EXPRESSION ]} trick that Greg Hewgill mentioned.

There's also the Interpolation module, which allows you to do arbitrary transformations on the values you're interpolating (like encode HTML entities) in addition to evaluating expressions.

2010-10-15