Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: How do you use the if pragma?

by tobyink (Abbot)
on Apr 08, 2013 at 23:27 UTC ( #1027609=note: print w/ replies, xml ) Need Help??


in reply to How do you use the if pragma?

My most frequent uses of if seem to be:

# Loading either "mro" or "MRO::Compat" depending # on Perl version... # use if $] >= 5.010, 'mro'; use if $] < 5.010, 'MRO::Compat'; # Load UNIVERSAL::DOES for Perl prior to 5.10. # use if $] < 5.010, 'UNIVERSAL::DOES';

It's pretty easy to emulate it anyway:

# Loading either "mro" or "MRO::Compat" depending # on Perl version... # BEGIN { if ($] >= 5.010) { require mro; mro->import } else { require MRO::Compat; MRO::Compat->import } }; # Load UNIVERSAL::DOES for Perl prior to 5.10. # BEGIN { require 'UNIVERSAL::DOES' if $] < 5.010; };

CPAN also has unless.

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name


Comment on Re: How do you use the if pragma?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2014-07-26 02:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls