Connecting Tech Pros Worldwide Help | Site Map

How to declare global constants?

  #1  
Old April 30th, 2007, 05:55 AM
Louis
Guest
 
Posts: n/a
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.
  #2  
Old April 30th, 2007, 06:15 PM
Jim Gibson
Guest
 
Posts: n/a

re: How to declare global constants?


In article <zyeZh.8362$Dq6.6529@edtnps82>, Louis <t051315@hotmail.com>
wrote:
Quote:
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
  #3  
Old April 30th, 2007, 07:25 PM
Louis
Guest
 
Posts: n/a

re: How to declare global constants?


Jim Gibson wrote:
Quote:
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.
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to declare global variables. shrek123 answers 5 October 23rd, 2007 02:53 PM
no global constants in global.asax? 2obvious answers 1 November 18th, 2005 06:18 PM
Global constants and object Marty answers 8 November 17th, 2005 05:08 AM
can you declare global scope in an included file and see those variables throughout other code? NotGiven answers 5 July 17th, 2005 09:20 AM