Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > including files in perl

Reply
Thread Tools

including files in perl

 
 
brad
Guest
Posts: n/a
 
      02-06-2004
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
 
Reply With Quote
 
 
 
 
Walter Roberson
Guest
Posts: n/a
 
      02-06-2004
In article <(E-Mail Removed) >,
brad <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      02-07-2004

http://www.velocityreviews.com/forums/(E-Mail Removed) (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 * (E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 5.38 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? PerlFAQ Server Perl Misc 0 02-11-2011 05:00 AM
including .specification files (or other "dot" files) in RakePackage on Linux/Mac OS X Nathan Beyer Ruby 0 11-15-2009 09:34 PM
How to avoid including C files in other C files in an old code base Raman C Programming 5 06-07-2008 08:43 PM
problem including perl header files shruti C Programming 2 05-15-2006 08:04 PM
problem including perl header files shruti.dabhade@gmail.com Perl Misc 2 05-15-2006 05:01 PM



Advertisments