declaring constants

Discussion in 'Perl' started by Troy Knight, Jul 25, 2004.

  1. Troy Knight

    Troy Knight Guest

    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
    Troy Knight, Jul 25, 2004
    #1
    1. Advertising

  2. Troy Knight

    Guest

    "Troy Knight" <> wrote in message news:<jLHMc.87693$>...
    > 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 28, 2004
    #2
    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. Marius Vollmer
    Replies:
    6
    Views:
    824
    Jim Lewis
    Dec 10, 2003
  2. valentin tihomirov
    Replies:
    1
    Views:
    578
    Jonathan Bromley
    Feb 18, 2004
  3. Generic Usenet Account

    Declaring constants within the scope of a class

    Generic Usenet Account, Mar 15, 2005, in forum: C++
    Replies:
    5
    Views:
    3,584
    Howard
    Mar 15, 2005
  4. Declaring constants

    , May 29, 2006, in forum: VHDL
    Replies:
    5
    Views:
    705
  5. Sriram Chadalavada

    Defining/declaring constants in Python

    Sriram Chadalavada, Jul 28, 2003, in forum: Python
    Replies:
    2
    Views:
    4,193
    Michael Hudson
    Jul 29, 2003
Loading...

Share This Page