A
Amanda aman_DO_da345
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
--
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
--