[25891] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8119 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 26 21:05:22 2005

Date: Thu, 26 May 2005 18:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 26 May 2005     Volume: 10 Number: 8119

Today's topics:
    Re: Ignorant question regarding includes <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 26 May 2005 19:30:26 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Ignorant question regarding includes
Message-Id: <slrnd9cqh2.b1e.tadmc@magna.augustmail.com>

Debo <mddibern@NOSPAM.student.cs.uwaterloo.ca> wrote:
> Hello there,
> 
> I'd like to set up my application so that a whole bunch of global
> 'constants' are available merely by including the file somehow.
> 
> The gist of what I'm trying to do is something like this:
> 
> 
> ***In constants.pl:
> 
> my $constant1 = 'some value';
  ^^
> my $constant2 = 'some other value';
  ^^


Lexical variables are never visible across file boundaries,
for that you need the other kind of variable (package variables).

See also:

   "Coping with Scoping":

      http://perl.plover.com/FAQs/Namespaces.html



> ***In somefile.pl:
> 
> require constants.pl;


require requires a string.

You should put quotes around strings.


> if ('hello' eq $constant1)


> Any suggestions? 


Make a proper module and export the variables via Exporter.

Perhaps even better, have a single global hash instead of
a "whole bunch" of individual variables.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8119
***************************************


home help back first fref pref prev next nref lref last post