On Fri, Sep 14, 2018 at 7:32 PM ToddAndMargo <toddandma...@zoho.com <mailto:toddandma...@zoho.com>> wrote:

    What is this all about?


    $ p6 'my $x="abc"; my $y="def"; say "$x::$y";'
    ===SORRY!=== Error while compiling -e
    Malformed lookup of ::$y; please use ::('$y'), ::{'$y'}, or ::<$y>
    at -e:1
    ------> my $x="abc"; my $y="def"; say "$x⏏::$y";

    $ p6 'my $x="abc"; my $y="def"; say "$x\::$y";'
    abc::def

    $ p6 'say "abc::def";'
    abc::def

    What does the compiler think `::$y` is?

    Many thanks,
    -T

On 09/14/2018 04:37 PM, Brandon Allbery wrote:
It thinks it's interpolating a variable $x::... and then it gets stuck because it sees $y instead of the rest of a variable name. You can use braces to control what's part of the name:

pyanfar Z$ 6 'my $x = "abc"; my $y = "def"; say "{$x}::{$y}"'
abc::def

Otherwise, you couldn't interpolate the name of a variable $x::y in some other module.


Makes sense, I think.  I have just been using an escape
       $a\::$b

Reply via email to