Thank you, Rolf (and also other guys).

Personally I'd prefer for such "basic thing" something "exactly explicit" just where it's used, without packaging/hiding it in the subroutine defined elsewhere. I prefer using custom subroutines for bit less simple logic (just personal preference).

About no return from dying: yes, I really don't need returning from that death, therefore I called that "exploiting". But maybe somebody will find also other use cases for such "assignary" operator, not just this one.

In the context of my practise (as used in my scripts and modules), I initialize (define) all my local variables just with heir my, to be more explict, what type of value are they predetermined to bear (number, string, hashref, etc.), e. g.:

my $string = '';

and therefore I don't need to differentiate undef from '', which means "not set" in my example.

But, in case, of undefined variable used in assignary, e.g.:

my $some_undefined_var; $some_undefined_var ?= die 'already set' : 'survived';

on my opionion, it could stay alive, and "use of uninitialized value" warning raised on use warnings;.


In reply to Re^4: RFC: "assignary" operator ?= : by richard.sharpe
in thread RFC: "assignary" operator ?= : by richard.sharpe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.