By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,723 Members | 1,655 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,723 IT Pros & Developers. It's quick & easy.

Need advice on include-like file for Perl

P: n/a


Hi!

I've done most of my programming in C/C++ and a little in Perl,
though until recently I have stayed away from Perl OOP. Now I'm
writing my first suite of classes in Perl, and I wonder how best
to set up something analogous to an include file in C/C++ consisting
of definitions of constants to be used by all the classes in this
suite. The main class in this suite is called SMS. My idea was
to create a file SMS_Constants.pm to collect all these constants:

# file SMS_Constants.pm
package SMS; # keep "prefix" short
our $Constant_1 = 'some value';
our $Constant_2 = 'another value';
our $Constant_3 = 'you get the picture';
# etc.
1;

so that other code could access these constants as $SMS::Constant_1,
etc. after first invoking "use SMS_Constants.pm" in a spirit similar
C/C++ programs' use of '# include "some_constants.h"'.

Is this what's usually done in Perl? Are there any obvious problems
with this approach? I suppose that TMTOWTDI, but it would be
instructive to read who different Perl programmers go about doing
this.

Many thanks in advance!

Amanda
--
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In <c5**********@reader2.panix.com> Amanda aman_DO_da345@al_THE_ter_OBVIOUS_n.org writes:
Hi! I've done most of my programming in C/C++ and a little in Perl...

I am very sorry! By a cut-and-paste error, this post ended in the
wrong NG.

*blush*

A.
--
Jul 20 '05 #2

P: n/a
In <c5**********@reader2.panix.com> Amanda aman_DO_da345@al_THE_ter_OBVIOUS_n.org writes:
Hi! I've done most of my programming in C/C++ and a little in Perl...

I am very sorry! By a cut-and-paste error, this post ended in the
wrong NG.

*blush*

A.
--
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.