user3543078
user3543078

Reputation: 85

Perl can't find module listed in same directory as script

I need to keep any custom modules in the same-ish directory as my script.

I keep getting this error suggesting that Perl can't "see" the module I'm declaring

Global symbol "$employment_type" requires explicit package name at early_enrollments_by_term.pl line 260.

Execution of early_enrollments_by_term.pl aborted due to compilation errors.

My module is Hash.pm and is in directory /home/pgb2/canvas/canvas-sis-feeds/scripts/lib/Custom

Hash.pm

package Custom::Hash;

My script is early_enrollments_by_term.pl and lives in /home/pgb2/canvas/canvas-sis-feeds/scripts/

early_enrollments_by_term.pl

#!/usr/bin/perl

use strict;

use DBI;

use lib qw(/home/pgb2/canvas/canvas-sis-feeds/scripts/lib);

use Custom::Hash;

my $enrollment_type = $Custom::Hash::enrollment_hash{$role};  # line 259
print "\nenrollment_type: $employment_type\n";                # line 260

Would anyone be able to tell why it's not finding the module?

Upvotes: 1

Views: 715

Answers (1)

Borodin
Borodin

Reputation: 126722

Although you have shown very little of your code, the problem would presumably be that you have declared $enrollment_type and tried to use $employment_type, which has not been declared

Had perl been unable to find the module, it is the use Custom::Hash statement that would throw the error

Upvotes: 4

Related Questions