On Fri, Apr 20, 2001 at 07:21:26PM -0700, Benothmane, Mohamed wrote:
: I am trying to include a header file in each Perl package (files with .pm
: extension), but the constants declared in the header files are not
: recognized anymore.  The only way I found to go around this problem is
: copying the same header file with different names and then I include each
: copy with different name in each package.  Why can't I just use one header
: file and include in each package?  Any help would really be appreciated.

Mohamed,

I am a bit confused, because Perl doesn't really have "header" files.
If you would like to make a Perl module that exports constants, I can
help you with that.

The following is a module that exports PI as a constant:

package Export::Pie;

use strict;
use constant PI => 4 * atan2( 1, 1 );

require Exporter;

our @ISA     = qw[ Exporter ];
our @EXPORT  = qw[ PI ]
our $VERSION = '0.01';

1;

__END__

You could then use this module (Export/Pie.pm) in a program or other
module like this:

use Export::Pie;

print "Pi is " . PI;

I hope this helps, and don't forget to read:

perldoc perlmod
perldoc perlmodlib
perldoc constant
perldoc Exporter

Enjoy!

-- 
Casey West

Reply via email to