http://qs321.pair.com?node_id=721195

lepetitalbert has asked for the wisdom of the Perl Monks concerning the following question:

Hello dear Monks,

I have a script which needs Image::Magick for some functions but not all.

I'd like to disable these functions if Image::Magick is not installed

I tried to do something like :
pseudo-code

$is_magick = 0; if ( is_installed Image::Magick ) { $is_magick = 1 }

and later

if ( $is_magick = 0 ) { print "Image::Magick functions disabled"; } else { do stuff with Image::Magick ... }

I found some post on perlmonks and other places but nothing works

stuff like

our $is_magick = 0; eval 'require GD'; if ($@) { # problems with GD, fall back to non-GD } else { # we have GD, go for it! $is_magick = 1; }

or

our $is_magick = 1; BEGIN { unless (eval "use Image::Magick") { $is_magick = 0; } }

The first example didn't change $is_magick, the second one gives me an error 500.

How can do this ?

Thanks

Have a nice day !

updated fixed typo

"There is only one good, namely knowledge, and only one evil, namely ignorance." Socrates