Using the constant pragma is best. Perldoc constant. Sent from my iPhone
On Mar 5, 2013, at 7:59 AM, Mike Stok <[email protected]> wrote: > Don't you need to export the constant? > > Maybe this isn't the modern way to do it, but: > > ratdog:tmp mike$ cat constant1.pm > package constant1; > > require Exporter; > @ISA = qw( Exporter ); > @EXPORT = qw( NUM_MUSKETEERS ); > > sub NUM_MUSKETEERS() {3} > > 1; > ratdog:tmp mike$ perl script.pl > mod1: 1 > mod1: 2 > mod1: 3 > mod2: 1 > mod2: 2 > mod2: 3 > > Hope this helps, > > Mike > > On 2013-03-05, at 7:37 AM, "Greg London" <[email protected]> wrote: > >> >> OK, I've been coding since 5am, so I assume I'm just tired, >> but I can't figure this out. >> >> I have a bunch of perl constants that I put in a module. >> I'm trying to use that module in two different places. >> I'm getting an error: >> >> Bareword "CONSTANTNAME" not allowed while "strict subs" in use >> >> >> Here's a simplified testcase. >> >> >> FILENAME: constant1.pm >> ------------------------ >> sub NUM_MUSKETEERS() {3} >> >> 1; >> >> >> FILENAME: mod1.pm >> ------------------------ >> >> package mod1; >> >> use warnings; >> use strict; >> >> use constant1; >> >> foreach my $i (1..NUM_MUSKETEERS){ >> print "mod1: $i\n"; >> } >> >> 1; >> >> >> FILENAME: mod2.pm >> ------------------------ >> >> package mod2; >> >> use warnings; >> use strict; >> >> use constant1; >> >> foreach my $i (1..NUM_MUSKETEERS){ >> print "mod2: $i\n"; >> } >> >> 1; >> >> >> >> FILENAME: script.pl >> ------------------------- >> >> #!/usr/bin/perl >> >> use warnings; >> use strict; >> use mod1; >> use mod2; >> >> >> >> >> >> >> _______________________________________________ >> Boston-pm mailing list >> [email protected] >> http://mail.pm.org/mailman/listinfo/boston-pm > > -- > > Mike Stok <[email protected]> > http://www.stok.ca/~mike/ > > The "`Stok' disclaimers" apply. > > > > > > _______________________________________________ > Boston-pm mailing list > [email protected] > http://mail.pm.org/mailman/listinfo/boston-pm _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

