[% setvar title Perl resource configuration %]
Note: these documents may be out of date. Do not use as reference! |
To see what is currently happening visit http://www.perl6.org/
Perl resource configuration
Maintainer: Jonathan Scott Duff <duff@pobox.com> Date: 16 Aug 2000 Last Modified: 1 Sep 2000 Mailing List: perl6-language@perl.org Number: 114 Version: 2 Status: Developing
Perl should provide a mechanism to have code automatically loaded from a file upon interpreter startup.
Many programs have so-called "resource configuration" files (at least that's what I call them) that are loaded and executed upon program startup. Some example programs that have this ability include bash, mutt, and python. Perl should do something similar.
The first version of this RFC proposed two "rc" files: /etc/perlrc
and
~/.perlrc
[1]. However, the author of this RFC has decided that the
motivations behind /etc/perlrc
are misguided. If the administrator
of the system wishes to impose global behavior, he can and should do
so through the environment.
This RFC now proposes that Perl 6 support a single per-user "rc" file,
~/.perlrc
, that is loaded for each Perl program run by the user.
This file would simply be Perl code that is loaded and executed just as if
the following were at the top of each perl program executed by the user:
BEGIN { $_ = "$ENV{HOME}/.perlrc"; require if -e; }
Execution of the ~/.perlrc
would not be the default behavior.
A command line switch would be needed to invoke the automatic loading.
For example:
#!/usr/bin/perl -r # ~/.perlrc is now loaded
Thus the ~/.perlrc
file could be used by the user to setup common
defaults such as diagnostics or stricture for all of his/her programs.
Also, if RFC 184 (interactive mode for perl) is adopted, it may be
desirable to automatically execute the contents of ~/.perlrc
upon
entered an interactive session regardless of whether or not the
command line switch that triggers loading of ~/.perlrc
was used.
Nathan Wiger <nate@wiger.org> brought up the issue of packaging a perl
program and/or module that may rely on settings in the local ~/.perlrc
which could be radically different from the settings in the ~/.perlrc
on the client's side. It is suggested that a warning be emitted (if
warnings are turned on) when the programmer uses the command line option
to the the "rc file". How do the other programming languages that have an
"rc file" concept handle this problem (e.g., python)?
An option would need to be added to explicitly make perl look for the
~/.perlrc
file. The author of this RFC tentatively suggests -r
.
Only those programs that wish to take advantage of this feature need translating from Perl5. This is best left to the programmer rather than an automated translator.
[1] Note that this RFC is couched in terms of a Unix-ish filesystem. Perl should support the analogous concept for the other platforms on which it compiles.
Perl 5.6.0 Documentation
From the man page for python 1.6
bash documentation: www.gnu.org#SEC61
The mutt man page: www.mutt.org
RFC 184: Perl should support an interactive mode: