Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: RFC: Defined-Or for before Perl 5.10

by JavaFan (Canon)
on Oct 29, 2010 at 17:27 UTC ( #868364=note: print w/ replies, xml ) Need Help??


in reply to RFC: Defined-Or for before Perl 5.10

H.Merijn Brand used to maintain patches against 5.8.x to enable // and //=. You may want to check his CPAN account to see whether they are still there.

Note that if you want to go the subroutine way, you could also do:

use List::Util qw[first]; my $val = first {defined} undef, 0;


Comment on Re: RFC: Defined-Or for before Perl 5.10
Download Code
Re^2: RFC: Defined-Or for before Perl 5.10
by molecules (Monk) on Oct 29, 2010 at 18:03 UTC

    Thanks!

    The patches are huge, running 350-500K! (c.f. dor-5.8.8-34438.diff)

    He names the patch files starting with "dor". Would that be a better name than "defined_or"?

      He names the patch files starting with "dor". Would that be a better name than "defined_or"?
      I personally prefer "dor" to "defined_or". Actually, I quite like Larry's original "err" -- though the majority of P5P seemed to prefer "dor", based on some long P5P threads. To be "consistent" with Perl 6, you might even consider "orelse".

      Note that while the // "defined or" operator was added to Perl 5.10, the low precedence version of this operator was not. AFAICT, this low precedence operator morphed from err to dor to orelse; orelse is in Perl 6 as a similar, but not identical, low precedence version of //, but it's not in Perl 5 and I'm not aware of any plans to add it. See also this Larry response on perl6-language mailing list.

        Actually, IIRC, for quite a while, 5.9.x *had* err, and it was culled not to long before 5.10 came out due to some backwards compatability issues noone seemed to be able to resolve.
Re^2: RFC: Defined-Or for before Perl 5.10
by Anonymous Monk on Oct 29, 2010 at 18:28 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2015-07-07 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (90 votes), past polls