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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.