I'm trying to give a "human readable message" for an application if there's missing modules upon running the script. However I've stumbled upon an issue when it comes to loading modules with qw.
I've tried the following:
use strict;
...
if ( ! eval { require Proc::Daemon;1; } ) {
push (@install_packages, "Proc::Daemon");
} else {
Proc::Daemon->import(qw( SOCK_STREAM SOMAXCONN ));
}
However it fails
Bareword "SOCK_STREAM" not allowed while "strict subs" in use at ./revmon.pl line 144.
Bareword "SOMAXCONN" not allowed while "strict subs" in use at ./revmon.pl line 144.
Using use obviously doesn't work as it will give the normal error-message
Can't locate Proc/Daemon.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .)
BEGIN failed--compilation aborted at ./revmon.pl line 11.
Adding * to the bareword doesn't help much either since it's only used once which will throw another error with use warnings;
Is there same way to work around this to get the BAREWORDS working properly when the module can be loaded successfully?