Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by shmem (Chancellor)
on Dec 07, 2019 at 17:38 UTC ( [id://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 (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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2024-04-25 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found