How to declare global constants?

L

Louis

I would like to declare a constant in a module (.pm), so other perl
scripts can use the module and the constant it contains.

I tried
use constant BASEDIR => 'path_name';
in the module.

But when I use this module, perl complains that BASEDIR is a bareword.

How do you make this work?

Really appreciate your comment.
 
J

Jim Gibson

Louis <[email protected]> said:
I would like to declare a constant in a module (.pm), so other perl
scripts can use the module and the constant it contains.

I tried
use constant BASEDIR => 'path_name';
in the module.

But when I use this module, perl complains that BASEDIR is a bareword.

How do you make this work?

Really appreciate your comment.

You should post a complete, minimal program that demonstrates the
problem. Otherwise, we are just guessing at the cause.

One guess: are you referring to BASEDIR in the program that uses the
module or the actual name <module>::BASEDIR?

This group is defunct. Try comp.lang.perl.misc in the future.
 
L

Louis

Jim said:
You should post a complete, minimal program that demonstrates the
problem. Otherwise, we are just guessing at the cause.

One guess: are you referring to BASEDIR in the program that uses the
module or the actual name <module>::BASEDIR?

This group is defunct. Try comp.lang.perl.misc in the future.
Thanks Jim,

I forgot about the prefix <module>::
Thank you.

I will use the other group.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top