0
votes

I am trying to loading Digest::MD5 from the directory my Perl script is existing in (since I can't install through PPM on my enviroment.)

I've tried a bunch of combinations, but what appears to work on Strawberry perl on Windows, but not in Red Hat linux is having a Digest directory with MD5.pm, base.pm, and file.pm in it. Then I am using this code to load the module.

use FindBin;
use lib "$FindBin::Bin/";
use Digest::MD5 qw(md5_hex);

But I get this error:

Can't locate loadable object for module Digest::MD5 in @INC (@INC contains: /opt/myapp/bin/script/ /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./app.pl line 21. Compilation failed in require at ./app.pl line 21. BEGIN failed--compilation aborted at ./app.pl line 21.

I'm tired of banging my head on my desk, anyone have any ideas?

Edit:

This was marked as an exact duplicate of a very different question. This is not about a missing module, it is about including a module directly with a perl script so it can be packaged and installed without installing a module through PPM or CPAN or something.

1
How did you install Digest::MD5?melpomene
Your script is in /opt/myapp/bin/script/ and you have no lib directory in between?simbabque
@melpomene I downloaded the source .pm files.marcusds
Yeah, that's not going to work. Why not use the Red Hat system package for Digest::MD5?melpomene

1 Answers

0
votes

What you may not realize is that the :: in Digest::MD5 implies that MD5.pm is expected to be in a parent folder/directory named Digest. Make a directory named Digest, move MD5.pm into it and you should be fine.

Other ways to have Perl look in alternate locations are to set the environment variable PERL5LIB

setenv PERL5LIB /opt/myapp/bin/script

or the generally frowned upon manipulation of @INC

BEGIN {
  push @INC, "/opt/myapp/bin/script";
}