467,104 Members | 1,003 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,104 developers. It's quick & easy.

Need advice on include-like file for Perl



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
  • viewed: 1443
Share:
2 Replies
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
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.

Similar topics

2 posts views Thread by Adam Schroeder | last post: by
11 posts views Thread by ma740988@gmail.com | last post: by
11 posts views Thread by Milton | last post: by
9 posts views Thread by kupiko | last post: by
reply views Thread by CodeMonkey | last post: by
1 post views Thread by newatthis | last post: by
2 posts views Thread by tootsuite@gmail.com | last post: by
2 posts views Thread by Carl R. Davies | last post: by
20 posts views Thread by merrittr | last post: by
8 posts views Thread by Jim Cobban | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.