0

Possible Duplicate:
Separating configuration data and script logic in Perl scripts

StevedoreUtil.pm sets a value used for email addresses:

my $STEVE_SITE_EMAIL_DOMAIN = "mydomain.net";

Unfortunately, this should not be hard coded in the Perl script. Is there a standard way to set a value like this once when the application is first installed?

See Stevedore Project on launchpad.net and the Stevedore Web Site for the context of StevedoreUtil.pm.

Community
  • 1
  • 1
CW Holeman II
  • 4,661
  • 7
  • 41
  • 72
  • 1
    No, of course configuration should not be hard-coded in the script. Configuration variables should live in configuration files. I am not sure if you are just trying to publicize your stuff with this post, but, FYI, `$#ARGV+1 == 2` is better written as `@ARGV == 2`. – Sinan Ünür Nov 02 '10 at 21:11
  • @Ether how does that address the issue of setting the value at install time. The question is also asking for a standard way rather than say the faster execution time, the easiest to code or the easiest to maintain. – CW Holeman II Nov 02 '10 at 21:46
  • W.Holeman: your installer could generate a config file, or insert values into an existing one. That question does cover the various classic implementations, including the tradeoffs of each. – Ether Nov 02 '10 at 21:48

2 Answers2

1

Both ExtUtils::MakeMaker and Module::Build have facilities for running scripts with the *.PL extension to create new files at installation time. Some distributions include files with names like Foo.pm.PL to create files like Foo.pm.

socket puppet
  • 3,191
  • 20
  • 16
0

Well, the value of $Config{perladmin} out of the Config module has something that works for Perl proper and is determined at build time:

% perl -V:perladmin
perladmin='tchrist@chthon.perl.com';

However, I’m unaware of any sort of convention for supporting that sort of notion for a given module/class/file. It’s hard enough getting UNIVERSAL->VERSION() support.

Still, there may be something to your idea. I’d be somewhat surprised if it hadn’t already been discussed elsewhere. A really quick check on the documentation for the various module build mechanisms didn’t turn up anything obvious.

tchrist
  • 78,834
  • 30
  • 123
  • 180