The accepted solution seems to be to use eval with require
(You can't do a 'use' inside an 'eval').
my $loaded;
{
# ignore warnings if subs are being redefined
local $^W = 0;
$loaded = eval "require MQSeries";
}
if(!defined($loaded))
{
print "Can't load MQSeries: $@\n";
}
Note: you'll need an 'import' in there if you also want to import exported methods etc.
update: Apparently 'use' does work in 'eval', I can't for the life of me remember why I thought you can't, must have been some reason that I use require.. hohum..
C.