Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

disable functions if module not installed

by lepetitalbert (Monsignor)
on Nov 03, 2008 at 21:21 UTC ( #721195=perlquestion: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $is_magick = 0;
    
    if ( is_installed Image::Magick ) { $is_magick = 1 }
    
  2. or download this
    if ( $is_magick = 0 ) {
    
    ...
    
      do stuff with Image::Magick ...
    }
    
  3. or download this
    our $is_magick = 0;
    eval 'require GD';
    ...
      # we have GD, go for it!
      $is_magick = 1;
    }
    
  4. or download this
    our $is_magick = 1;
    BEGIN {
    ...
        $is_magick = 0;
      }
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://721195]
Approved by Limbic~Region
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (12)
As of 2014-12-26 15:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (171 votes), past polls