Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: CPAN Trojan Horses

by tobyink (Abbot)
on Jun 28, 2013 at 19:52 UTC ( #1041332=note: print w/ replies, xml ) Need Help??

in reply to CPAN Trojan Horses

The easy way to do optional dependencies is along these lines:

use constant HAS_LWP => eval "require LWP::UserAgent"; ...; update_cache() if HAS_LWP; my $data = read_cache();

In terms of META.yml/META.json, there is a facility to indicate optional dependencies, though I don't see it used very often.

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

Comment on Re: CPAN Trojan Horses
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2015-10-07 18:55 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (197 votes), past polls