use 'require' instead of 'use', and enclose it inside an 'eval' block.
For example, in one of my plugins, I use the following code:
# -----------------------------------------------------------------------------
# This function displays an HTML formatted message that will display any
# instructions/information to the user before they install the plugin.
#
my $hasXML = eval { require XML::Simple } ? "pass" : '<font color="red">fail</font>';
my $hasHTML = eval { require HTML::TokeParser } ? "pass" : '<font color="red">fail</font>';
my $inst_msg = <<END_OF_HTML;
Required modules: <br />
<ul>
<li>XML::Simple -> $hasXML</li>
<li>HTML::TokeParser -> $hasHTML</li>
</ul>
<br />
Required update for GT::CGI:<br />
<br />
<a href="http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=292660">Go here for details.</a><br />
<br />
Please ensure the above prerequisites are installed before continuing.
END_OF_HTML
return $inst_msg;
}
Philip
------------------
Limecat is not pleased.
Code:
eval { require Image::Magick }For example, in one of my plugins, I use the following code:
Code:
sub pre_install { # -----------------------------------------------------------------------------
# This function displays an HTML formatted message that will display any
# instructions/information to the user before they install the plugin.
#
my $hasXML = eval { require XML::Simple } ? "pass" : '<font color="red">fail</font>';
my $hasHTML = eval { require HTML::TokeParser } ? "pass" : '<font color="red">fail</font>';
my $inst_msg = <<END_OF_HTML;
Required modules: <br />
<ul>
<li>XML::Simple -> $hasXML</li>
<li>HTML::TokeParser -> $hasHTML</li>
</ul>
<br />
Required update for GT::CGI:<br />
<br />
<a href="http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=292660">Go here for details.</a><br />
<br />
Please ensure the above prerequisites are installed before continuing.
END_OF_HTML
return $inst_msg;
}
Philip
------------------
Limecat is not pleased.