• useful technique for initializing something with a reference

    From Rainer Weikusat@21:1/5 to All on Mon Nov 1 18:44:15 2021
    Minor gem of Perl's support for a conditional assignment operators.

    Assuming that $x holds a reference to some container and a slot/ key
    of it is supposed to refer to another container which is initially undef
    and a variable made $y is supposed to be assigned this reference for
    easier subsequent access, this can be set up with the single line

    $y = $$x[0] //= {};

    If the value of $$x[0] is defined, ie, has already been initialized,
    it'll be assigned to $y. Otherwise a reference to an anonymous hash is
    assigned to $$x[0] and then to $y.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)