Reputation: 1286
I have these three files
Constants/Requests.pm
#!/usr/bin/perl
use strict;
use base 'Exporter';
use constant MR_NOACTION => 0;
use constant MR_START => 1;
use constant MR_STOP => 2;
our @EXPORT = (
'MR_NOACTION',
'MR_START',
'MR_STOP'
);
1;
JobManDB.pm
#!/usr/bin/perl
package JobManDB;
use strict;
use warnings;
use constant WEB_DB_FILE => "db/web.db";
use constant MASTER_DB_FILE => "db/master.db";
use Constants::Requests;
sub new
{
print "Ahoj: " . MR_NOACTION . "\n";
...
Master.pm
#!/usr/bin/perl
package Master;
use strict;
use warnings;
use Time::HiRes qw( usleep );
use Data::Dumper;
use JobManDB; # use #1
use Constants::Requests; # use #2
...
Program as posted is working, if but if I swith use #1
with use #2
the compilation fails with error:
Bareword "MR_NOACTION" not allowed while "strict subs" in use at lib/JobManDB.pm line 26.
(line 26 is the line in 'new' subroutine). I would like to know why. Thank you.
EDIT:
Another issue is, that if I add line package Requests;
at the beginning of Requests.pm, the compilation fails with the same error but independently on order of 'uses'.
Upvotes: 1
Views: 101
Reputation:
The Requests.pm
file is missing its package declaration, package Constants::Requests;
.
Upvotes: 3