http://qs321.pair.com?node_id=11109814


in reply to Re^3: RFC: "assignary" operator ?= :
in thread RFC: "assignary" operator ?= :

Yes with a properly named custom-function operating on an alias.
init $var1 => 'value1'; # pretty elegant, right?

No, not at all. First, init() is a poor name which doesn't, by name, tell at all what it is doing. Second, the sub you wrote isn't at all ternary in any way, since it misses $_[2]. Third and last, function LIST doesn't tell at first glance that it is about conditional assignment to $_[0] from either $_[1] or $_[2] based on defined-ness of $_[0].

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^5: RFC: "assignary" operator ?= :
by LanX (Saint) on Dec 07, 2019 at 18:01 UTC
    > Second, the sub you wrote isn't at all ternary in any way

    It's an XY problem, the use case wasn't ternary from the beginning.

    But you're welcome to impress us with a better solution.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice