A. Pagaltzis wrote:

[...]

Might Pod::Constants help?

    =begin constants

        FOO  => 1
        BAR  => 2
        QUUX => 3

    =end constants

And then in the code:

    use Pod::Constants -trim => 1, constants => \my %const;
    use constants \%const;


Thanks for the suggestion, Aristotle. For the record, I had to tweak it a bit. This works:

#! /usr/local/bin/perl -w

use strict;

BEGIN {
    my %const;
    use Pod::Constants -trim => 1, constants => \%const;
    use constant \%const;
}

=begin constants

FOO  => 1
BAR  => 2
QUUX => 3

=cut

my @list = qw( fazzo gascoigne godolphin waste );
print $list[BAR], $/;

__END__

My only regret is that the C<use constant {}> construct only became legal in 5.8, and I don't think the tradeoff between the admittedly remarkable ease of use of this compared to cutting off 5.5, 5.6 is worthwhile.

So again I ask, is there nobody doing text substitutions/macro expansions on pm files on their way from the source directory to the ./blib/lib directory? It seems to me to be a useful technique, and I am surprised that nobody (is/admits to) using it.

Thanks,
David

--
Much of the propaganda that passes for news in our own society is given to immobilising and pacifying people and diverting them from the idea that they can confront power. -- John Pilger

Reply via email to