including files in perl

Discussion in 'Perl Misc' started by brad, Feb 6, 2004.

  1. brad

    brad Guest

    I have a list of about 100 constants that I want to use in several
    files.
    I have made this list of constants into a file with extension .hpl as
    in .h for perl. anyways, I can use do or require to include this
    file, however, the constants are not avaliable to use as if i had
    declared them in the calling perl file. To use these constants, I
    have to use the eval() function to so i say

    KEY_PRESS(KEY_1) normally where KEY_1 is a constant;

    when defining KEY_1 in another file and and calling it in function
    KEY_PRESS it looks like this:

    KEY_PRESS(eval(KEY_1))

    I do not want to have to use eval()

    why is this happening. This is not the case for variables. This is
    only happening for constants. Is there a better way to include other
    files into my perl programs. I need to have a comment where the perl
    program goes to the file i am calling executes and stores constants
    and comes back to the calling file and resumes as normal, require and
    do almost do this...
    please help
     
    brad, Feb 6, 2004
    #1
    1. Advertising

  2. In article <>,
    brad <> wrote:
    :I have a list of about 100 constants that I want to use in several
    :files.
    :I have made this list of constants into a file with extension .hpl as
    :in .h for perl. anyways, I can use do or require to include this
    :file, however, the constants are not avaliable to use as if i had
    :declared them in the calling perl file. To use these constants, I
    :have to use the eval() function to so i say

    :KEY_PRESS(KEY_1) normally where KEY_1 is a constant;

    :when defining KEY_1 in another file and and calling it in function
    :KEY_PRESS it looks like this:

    :KEY_PRESS(eval(KEY_1))

    :I do not want to have to use eval()

    How are you declaring the constants? Are you declaring them with
    "use constant" ? If you are, then they are becoming subroutines and
    you shouldn't have to eval() them, provided they are in the correct
    namespace.
    --
    Rome was built one paycheck at a time. -- Walter Roberson
     
    Walter Roberson, Feb 6, 2004
    #2
    1. Advertising

  3. brad

    Ben Morrow Guest

    (brad) wrote:
    > I have a list of about 100 constants that I want to use in several
    > files.
    > I have made this list of constants into a file with extension .hpl as
    > in .h for perl.


    The convention is for such files to have the extension '.ph': perl
    header.

    Ben

    --
    don't get my sympathy hanging out the 15th floor. you've changed the locks 3
    times, he still comes reeling though the door, and soon he'll get to you, teach
    you how to get to purest hell. you do it to yourself and that's what really
    hurts is you do it to yourself just you, you and noone else *
     
    Ben Morrow, Feb 7, 2004
    #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. shruti

    problem including perl header files

    shruti, May 15, 2006, in forum: C Programming
    Replies:
    2
    Views:
    463
    Keith Thompson
    May 15, 2006
  2. Raman
    Replies:
    5
    Views:
    366
    Lew Pitcher
    Jun 7, 2008
  3. Nathan Beyer
    Replies:
    0
    Views:
    112
    Nathan Beyer
    Nov 15, 2009
  4. Prince Kumar
    Replies:
    7
    Views:
    120
    Prince Kumar
    Nov 15, 2004
  5. Replies:
    2
    Views:
    210
    A. Sinan Unur
    May 15, 2006
Loading...

Share This Page