Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^4: RFC: "assignary" operator ?= :

by shmem (Chancellor)
on Dec 07, 2019 at 17:38 UTC ( #11109814=note: print w/replies, xml ) Need Help??

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 (Archbishop) 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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11109814]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2020-06-03 14:00 GMT
Find Nodes?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?

    Results (24 votes). Check out past polls.