You could also so something simpler like keep your constants in a package namespace and refer to them that way from other packages and the main daemon. This reduces clutter in the global namespace and only requires the file to be processed once for all of them.
For example:
A big problem with this approach is that you don't get compile time checking when you refer to a variable in another package. This is shown above with $Constants::THREE which only causes a problem at run time (at least in Perl 5.6.1).#file1.pl #!/usr/bin/perl -w use strict; use Constants; print "ONE=", $Constants::ONE, "\n"; print "TWO=", $Constants::TWO, "\n"; print "THREE=", $Constants::THREE, "\n"; #Constants.pm package Constants; $Constants::ONE = 1; $Constants::TWO = 2; 1;
Even with that drawback, this is a technique I use.
-- Eric Hammond
In reply to Re: Re: Re: the #include business
by esh
in thread the #include business
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |