473,382 Members | 1,258 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,382 software developers and data experts.

How to declare global constants?

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.
Apr 30 '07 #1
2 6015
In article <zyeZh.8362$Dq6.6529@edtnps82>, Louis <t0*****@hotmail.com>
wrote:
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.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Apr 30 '07 #2
Jim Gibson wrote:
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.
Apr 30 '07 #3

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

Similar topics

11
by: mrbog | last post by:
I have an array/hash that stores path information for my app. As in, what directory this is in, what directory that's in, what the name of the site is, what the products are called, etc. It's...
5
by: NotGiven | last post by:
I have an file I call using: require_once() In this file I have variables I'd like to use in the calling page and functions called by that page. How can I do this? example:
1
by: mark4asp | last post by:
What are the best methods for using global constants and variables? I've noticed that many people put all global constants in a file and include that file on every page. This is the best way of...
10
by: Matt | last post by:
Greetings, What are people's thoughts on global variables in C++? Why are we taught not to use them in programming? Is it true that if you are running two copies of the C program one copy can...
20
by: 2obvious | last post by:
I've been trying to create read-only global variables by creating constants (Const) in my global.asa, but I can't seem to reference them. Sticking them in an include works fine, but it seems more...
8
by: Johm | last post by:
In my codes i am often referring to one and the same controls.Is it possible to declare these controls only once and then insert them in all my functions and subs? For example, i am often...
1
by: Xiangliang Meng | last post by:
Hi, all. Recently, I find there is a way in our project to maintain a global set in many files by using preprocessing directives. I'm wondering if we could find a better method for this. Many...
4
by: Amadelle | last post by:
Hi all and thanks again in advance, What is the best way of defining global constants in a C# application? (A windows application with no windows forms - basically a set of classes). Would it be...
8
by: Thomas Coleman | last post by:
Ok, I've obviously discovered that Global.aspx has been completely changed in ..NET 2.0. However, I haven't figured out how to declare a constant that's available to any page in my application...
5
by: Will | last post by:
Hi, I'm linking into a library that has a global constant with the same name as one in my application. My references to the constant are being linked to the value in the library instead of the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.