[32554] in Perl-Users-Digest
Perl-Users Digest, Issue: 3820 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 18 03:09:22 2012
Date: Sun, 18 Nov 2012 00:09:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 18 Nov 2012 Volume: 11 Number: 3820
Today's topics:
Re: Module for common perl/shell/python constants <xemoth@gmail.com>
Re: Module for common perl/shell/python constants <jurgenex@hotmail.com>
Re: Module for common perl/shell/python constants <rweikusat@mssgmbh.com>
Re: Module for common perl/shell/python constants <rweikusat@mssgmbh.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 16 Nov 2012 21:30:01 -0800 (PST)
From: Owen <xemoth@gmail.com>
Subject: Re: Module for common perl/shell/python constants
Message-Id: <e8515ba1-176f-473e-bffa-22c5b3199e47@googlegroups.com>
On Friday, November 16, 2012 10:05:48 PM UTC+11, Hallvard Breien Furuseth wrote:
> Is there module which lets me write a single config file with
>
> integer/string constants which will be used by both Perl, Bash and
>
> Python? Preferably Perl would turn them into compile-time constants.
>
>
>
> E.g. I'd write "use Shellvars qw(foo.sh); where foo.sh
>
> would contain
>
> FOO = 3
>
> BAR = "baz"
>
> Hopefully
>
> BAD = "oops
>
> would fail rather than produce some arbitrary strange result.
Not sure exactly what you are after, but this may be a start, for perl anyway.
http://perldoc.perl.org/constant.html
Owen
------------------------------
Date: Sat, 17 Nov 2012 04:30:11 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Module for common perl/shell/python constants
Message-Id: <u90fa89cm57mgpu1ku9i95ap0ppp6iu26e@4ax.com>
Hallvard Breien Furuseth <h.b.furuseth@usit.uio.no> wrote:
>Is there module which lets me write a single config file with
>integer/string constants which will be used by both Perl, Bash and
>Python? Preferably Perl would turn them into compile-time constants.
>
>E.g. I'd write "use Shellvars qw(foo.sh); where foo.sh
>would contain
> FOO = 3
> BAR = "baz"
>Hopefully
> BAD = "oops
>would fail rather than produce some arbitrary strange result.
If you need configurations that are compatible across multiple languages
then typically the greatest common divisor is XML.
If the constants have to be compile-time (you may want to double-check
the reasoning for this requirement), then write a little script which
semi-automatically converts this master XML into whatever format is best
for language y.
jue
------------------------------
Date: Sat, 17 Nov 2012 14:42:22 +0000
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: Module for common perl/shell/python constants
Message-Id: <87d2zcjnox.fsf@sapphire.mobileactivedefense.com>
Hallvard Breien Furuseth <h.b.furuseth@usit.uio.no> writes:
> Is there module which lets me write a single config file with
> integer/string constants which will be used by both Perl, Bash and
> Python? Preferably Perl would turn them into compile-time
> constants.
The obvious solution for that would be a shell script which sets some
environment variables and invoking the Perl and Python code via wrapper
scripts configuring the environment first
A (somewhat crude) way to turn some environment variables into a Perl
constants could be:
--------------
package Shellvars;
sub import
{
my $caller;
$caller = caller();
shift;
for (@_) {
my $v = $ENV{$_};
*{$caller."::$_"} = sub () { $v; };
}
}
1;
--------------
--------------
use Shellvars qw(A PATH);
print(A, ' ', PATH, "\n");
--------------
This could be done in a much more sophisticated way, as can be seen in
constant.pm.
------------------------------
Date: Sat, 17 Nov 2012 15:09:21 +0000
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: Module for common perl/shell/python constants
Message-Id: <87fw489sgu.fsf@sapphire.mobileactivedefense.com>
Rainer Weikusat <rweikusat@mssgmbh.com> writes:
> Hallvard Breien Furuseth <h.b.furuseth@usit.uio.no> writes:
>> Is there module which lets me write a single config file with
>> integer/string constants which will be used by both Perl, Bash and
>> Python? Preferably Perl would turn them into compile-time
>> constants.
>
[...]
> A (somewhat crude) way to turn some environment variables into a Perl
> constants could be:
>
> --------------
> package Shellvars;
>
> sub import
[...]
> This could be done in a much more sophisticated way, as can be seen in
> constant.pm.
OTOH, one doesn't have to rewrite it if it could also be reused :-)
-----------------
package Shellvars2;
use constant;
sub import
{
shift;
@_ = ('MarmiteMermaid', { map { $_, $ENV{$_} } @_});
goto &constant::import;
}
1;
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 3820
***************************************