declaring constants

T

Troy Knight

This may seem like a dumb question but I've only just got back into perl
after a few years. I would be very grateful if someonme could answer this...

I'm trying to define constants which can be used across multiple source
files. This:

use constanr MY_CONSTANT => 5;

seems to only work if it's put in the main source file. How do I rectify
this so it can be used when it's defined in another source file?

Many thanks,

Troy Knight
 
N

nobull

Troy Knight said:
I'm trying to define constants which can be used across multiple source
files. This:

use constanr MY_CONSTANT => 5;

seems to only work if it's put in the main source file. How do I rectify
this so it can be used when it's defined in another source file?

Constants in Perl are subroutines (actually they are inlinable
subroutines).

You can export them just like any other subroutine. Typically you'd
do thois by using the Exporter module.

This newsgroup does not exist (see FAQ). Please do not start threads
here.
 

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

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top