I'm trying to create a number of related classes within the same namespace, but the classes can't seem to find each other.
I'm working within the namespace Crypt::HSXKPasswd. My .pm files are in the correct file paths in a folder ./lib (Crypt::HSXKPasswd is defined in ./lib/Crypt/HSXKPasswd.pm etc.).
Within my main module's constructor (Crypt::HSXKPasswd->new) I try to instantiate an object of type Crypt::HSXKPasswd::Dictionary::Default.
My test file is located in ., and has the following contents:
#!/usr/bin/perl
use strict;
use warnings;
use lib './lib';
use Crypt::HSXKPasswd;
my $hsxkpasswd = Crypt::HSXKPasswd->new();
It fails to execute with the following error:
Can't locate Crypt::HSXKPasswd::Dictionary::Default in @INC (@INC contains: ./lib /Library/Perl/5.18/darwin-thread-multi-2level /Library/Perl/5.18 /Network/Library/Perl/5.18/darwin-thread-multi-2level /Network/Library/Perl/5.18 /Library/Perl/Updates/5.18.2/darwin-thread-multi-2level /Library/Perl/Updates/5.18.2 /System/Library/Perl/5.18/darwin-thread-multi-2level /System/Library/Perl/5.18 /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level /System/Library/Perl/Extras/5.18 .) at lib/Crypt/HSXKPasswd.pm line 482.
Notice that @INC contains ./lib. The following head command shows that the .pm file for the module is located within the correct path under ./lib, and that it does define the correct package:
$ head -1 ./lib/Crypt/HSXKPasswd/Dictionary/Default.pm
package Crypt::HSXKPasswd::Dictionary::Default;
$
If the .pm file exists, defines the module, and is located in the correct path relative to a folder in @INC, why is Perl not seeing it?
Crypt::HSXKPasswdyou need touse Crypt::HSXKPasswd::Dictionary::Default;Crypt::HSXKPasswd::Dictionary::Default- the package name wasn't converted to file name. Could you please publish a couple lines around the use statement (before the change that fixed it)? Thank you.require "Foo::Bar";will try to load a Foo::Bar literally. You might want to replace it withuse Module::Load; load "Foo::Bar";- it should autodetect whether it's a file, or a package.