Is it possible to have a 'use' statement as conditional?
For example, rather than calling use Image::Magick; at the top of a .pm file, I want to include
it in the code, so that it is only included when/if the specific code gets executed.
use Image::Magick;
print $IN->header (-type=>'image/png', -cookie => $cookie);
}
else {
print $IN->header (-cookie => $cookie);
}
The problem I have is that when the code above is installed as a plugin for LinksSQL,
it generates an error if Image::Magick is not installed. Even if 'mode' is not 'IM'.
In other words, I have several 'modes' that I would like to use for creating an image.
The admin specifies the 'mode' to use via setup, i.e. IM for Image::Magick, GD for GD::Image, etc...
Then I call the script which should include the necessary module based on 'mode',
and ignore the other modules.
Additionally is there a way to check if a perl module is installed without
interupting the scripts execution?
If so, I could have the admin select a Perl Module to use for image creation
during the installation of the plugin, and install only the code that uses that module.
I would want to give them a dropdown menu of installed choices.
Any pointers/suggestions are appreciated.
Thank you,
Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com
For example, rather than calling use Image::Magick; at the top of a .pm file, I want to include
it in the code, so that it is only included when/if the specific code gets executed.
Code:
if ($mode eq 'IM') { use Image::Magick;
print $IN->header (-type=>'image/png', -cookie => $cookie);
}
else {
print $IN->header (-cookie => $cookie);
}
The problem I have is that when the code above is installed as a plugin for LinksSQL,
it generates an error if Image::Magick is not installed. Even if 'mode' is not 'IM'.
In other words, I have several 'modes' that I would like to use for creating an image.
The admin specifies the 'mode' to use via setup, i.e. IM for Image::Magick, GD for GD::Image, etc...
Then I call the script which should include the necessary module based on 'mode',
and ignore the other modules.
Additionally is there a way to check if a perl module is installed without
interupting the scripts execution?
If so, I could have the admin select a Perl Module to use for image creation
during the installation of the plugin, and install only the code that uses that module.
I would want to give them a dropdown menu of installed choices.
Any pointers/suggestions are appreciated.
Thank you,
Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com