develooper Front page | perl.perl5.porters | Postings from February 2019

Re: New defined-match operator

Thread Previous | Thread Next
David Nicol
February 22, 2019 15:48
Re: New defined-match operator
Message ID:
On Fri, Feb 22, 2019 at 9:21 AM Richard Leach <>

> More seriously, as well as checking for definedness, would there be
> some use for checking for existence? e.g. short circuiting if a nested
> hash structure doesn't have all the specified elements, rather than
> autovivifying some and then warning about uninitialized values.

This was essentially the "it" proposal, that got me subscribed to this
mailing list, some moons ago:

A variant of the "exists" test short circuits without vivifying, and has an
associated L-value accessor C<it> that exposes an alias to the target of
the last "exists" call. These would be lexically scoped to allow for

      (exists($some->{complicated}[$container]{access}{goes}{here}) and
something_arbitrary and print it)
         or print "no existo\n";
      it++; # increment
$some->{complicated}[$container]{access}{goes}{here}, autivivving if needed

currently the final level in nested hashes doesn't autoviv when used as a
subroutine argument; perhaps that magic could be extended to not autoviv
intermediates as well.

"I don't know about that, as it is outside of my area of expertise." --
competent specialized practitioners, all the time

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About