in reply to Re: Aren't there code refs as well as function refs?
in thread Aren't there code refs as well as function refs?

You missed some uses for curlies!

Delimiters for quote-like operators:

my $string = join q{ }, q(Hello), q/world/;

Hash keys:

my %hash; $hash{foo} = 42; @hash{ 'bar', 'baz' } = ( 666, 999 );

Unicode:

say "\N{DROMEDARY CAMEL}"; say "\x{1F42A}";

Replies are listed 'Best First'.
Re^3: Aren't there code refs as well as function refs?
by LanX (Saint) on Mar 05, 2023 at 14:34 UTC
    yeah, but
    • quote-like delimiters are a wildmark which fit everywhere
    • hash-keys - OK you are right - they belong to the already mentioned domain of hashes
    • in-string metas for unicode are a sub-language like the afore-mentioned regex, there might be even more like sprintf or formats
    and I also didn't mention dereferencing @{...} etc., but those belong to the same domain like @{name} and the un-strict symbolic derefs @{"na"."me"}

    in short: outside strings (and offsprings like regex) are curlies meant for the domains of

    • code-blocks
    • hashes
    • grouping of variable-symbols/refs

    Cheers Rolf
    (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
    Wikisyntax for the Monastery

      Technically the contents of ${...}, @{...}, %{...}, *{...}, and $#{...} are blocks, so you already covered them.

      use v5.10; no strict 'refs'; our $abc = 123; say ${ my @name = qw/a b c/; join q//, @name; };
        Hmm, indeed.

        Actually I was coming from the string-interpolation perspective, and didn't expect the following to "work"

        # https://perlmonks.org/?node_id=11150758 use v5.12.0; # incl. strict use warnings; no strict 'refs'; our @abc = 1..3; say "@{'a'.'bc'}";

        --->

        1 2 3

        Cheers Rolf
        (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
        Wikisyntax for the Monastery