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

New defined-match operator

Thread Next
From:
David Cantrell
Date:
February 21, 2019 12:12
Subject:
New defined-match operator
Message ID:
20190221115541.GB11111@bytemark.barnyard.co.uk
We all know how convenient it is to write this:

  $foo //= 'bar';

instead of:

  $foo = 'bar' unless(defined($foo));

Well, wouldn't it be nice to be able to write this:

  if($foo //~ /bar/)

instead of:

  if(defined($foo) && $foo =~ /bar/)

Thoughts?

-- 
David Cantrell | Enforcer, South London Linguistic Massive

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About