# New Ticket Created by  mt1957 
# Please include the string:  [perl #126796]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=126796 >


Variable interpolation is simple but with functions it gets wrong?

What I've understood is that everything not looked up from containers 
should be regarded as code
and must be placed in curly brackets. That seems not to be the case 
regarding functions/methods or at least it is not consistent.

Some examples

my $i = 10;
my $text = 'abc';

say "$i"                       # 10
say "$i.fmt"                   # 10.fmt
say "$i.fmt('%04d')"           # 0010
say "$i.fmt('%04d')($text)"    # Error Cannot find method 'CALL-ME'
say "$i.fmt\('%04d')"          # 10.fmt('%04d')
say "$i.m"                     # 10.m
say "$i.m()"                   # Method 'm' not found for invocant of 
class 'Int'
say "{$i.m}"                   # Method 'm' not found for invocant of 
class 'Int'


One can see that interpretation is triggered by the left round bracket. 
So when there is an object using methods without arguments one must use 
{} to get the method started. But when it needs arguments, round 
brackets do the trick automatically.
When errors pop up like 'Error Cannot find method 'CALL-ME'' it is not 
immediately clear that a bracket needs to be escaped.

Greetings,
Marcel Timmerman

Reply via email to