473,386 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

declaring constants

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
Jul 19 '05 #1
1 3383
"Troy Knight" <tr*****@blueyonder.co.uk> wrote in message news:<jL*******************@fe2.news.blueyonder.co .uk>...
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.
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sriram Chadalavada | last post by:
Hello everyone, I am a newbie to Python with experience in C programming. For my project, I am re-writing C routines as Python functions. I am currently using raw numerical values and was...
28
by: JKop | last post by:
const unsigned short int AmountHumanAdultTeeth = 32; inline unsigned short int AddFive(unsigned short int Numbr) { return Numbr + 5; } USE THESE!!
0
by: David W. Fenton | last post by:
Today I was working on a hideous old app that I created a long time ago that does a lot of showing/hiding/resizing of fields on one of the forms. I had used constants to store reference values for...
2
by: Edward Diener | last post by:
If I write: int x = { 1 }; that is fine with the compiler, but if I try to declare the array as const, meaning that it will not be changed: const int x = { 1 }; I receive the error...
7
by: Iain Mcleod | last post by:
Hi This must be an often encountered problem. I want to declare an abstract class or an interface with nothing but several static constants so that I can use polymorphism when I call each of them...
3
by: Buddy Robbins | last post by:
Hey folks, I'm trying to use the PathCleanupSpec function from the shell library. The function prototype is: int PathCleanupSpec( LPCWSTR pszDir, LPWSTR pszSpec) In the old days of VB6, I...
3
by: farseer | last post by:
i am getting "error C2057: expected constant expression" with the following code: ifstream f( argv ); f.seekg( 0, ios::end ); const long fSize = f.tellg(); f.close(); char content;
3
by: longbrmb | last post by:
I'm new to C++/CLI and my main background is Java. I'm trying to create an array of constants as a static member of a class. An example is shown below: public ref class TestClass { public:...
54
by: shuisheng | last post by:
Dear All, I am always confused in using constants in multiple files. For global constants, I got some clues from http://msdn.microsoft.com/en-us/library/0d45ty2d(VS.80).aspx So in header...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.