How to declare global constants?

Discussion in 'Perl' started by Louis, Apr 30, 2007.

  1. Louis

    Louis Guest

    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.
    Louis, Apr 30, 2007
    #1
    1. Advertising

  2. Louis

    Jim Gibson Guest

    In article <zyeZh.8362$Dq6.6529@edtnps82>, Louis <>
    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
    Jim Gibson, Apr 30, 2007
    #2
    1. Advertising

  3. Louis

    Louis Guest

    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.
    Louis, Apr 30, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. khawar
    Replies:
    1
    Views:
    7,285
    GastonQ
    Jul 10, 2003
  2. 2obvious

    no global constants in global.asax?

    2obvious, Sep 4, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,814
  3. Miguel Dias Moura

    How to declare a variable in the global scope?

    Miguel Dias Moura, Dec 14, 2004, in forum: ASP .Net
    Replies:
    41
    Views:
    10,819
    Vikesh Arora
    Dec 27, 2004
  4. Replies:
    18
    Views:
    624
    Fredrik Lundh
    Nov 30, 2005
  5. Replies:
    8
    Views:
    1,072
    Bruno Desthuilliers
    Feb 19, 2007
Loading...

Share This Page