ExtUtils-PerlPP

 view release on metacpan or  search on metacpan

PerlPP.pm  view on Meta::CPAN

=item config

A hash ref of preprocessor variables. In other words

    $ppp->{'config'}->{'var'} = 1;

is what C<-Dvar=val> is for the C preprocessor. Similarly you can compare

    delete $ppp->{'config'};

with C<-Uvar>. See L<"Macro replacements"> below. Unlike C, variables may
be arbitrarily complex, in particular you can use hash or array refs as
values.

Surprisingly you may pass a scalar value again: In that case the file of
the same name evaluated and the result is used as a configuration hash.
In other words

    $ppp->{'config'} = "myapp.cfg";

is similar to

PerlPP.pm  view on Meta::CPAN

    $parser->parse();

In order to be easily used within Makefiles, the ppp frontend can
read from @ARGV. That is, you can use the module like this:

    perl -MExtUtils::PerlPP -e ppp <infile> <outfile> <configfile>

from the commandline.


=head2 Macro replacements

The primary use of preprocessor variables (aka attributes of
C<$ppp->{'config'}>) is replacing patterns in the stream written to
the output file. With C<$c = $ppp->{'config'}> in mind the typical
patterns and their replacements are:

    ~~a~~		$c->{'a'}
    ~~b~~		$c->{'b'}
    ~~a->b~~		$c->{'a'}->{'b'}
    ~~a->e~~		$c->{'a'}->{'e'}

README  view on Meta::CPAN


    config  A hash ref of preprocessor variables. In other words

                $ppp->{'config'}->{'var'} = 1;

            is what `-Dvar=val' is for the C preprocessor. Similarly you can
            compare

                delete $ppp->{'config'};

            with `-Uvar'. See the section on "Macro replacements" below.
            Unlike C, variables may be arbitrarily complex, in particular
            you can use hash or array refs as values.

            Surprisingly you may pass a scalar value again: In that case the
            file of the same name evaluated and the result is used as a
            configuration hash. In other words

                $ppp->{'config'} = "myapp.cfg";

            is similar to

README  view on Meta::CPAN

                                           'config' => 'configfile');
        $parser->parse();

    In order to be easily used within Makefiles, the ppp frontend can read
    from @ARGV. That is, you can use the module like this:

        perl -MExtUtils::PerlPP -e ppp <infile> <outfile> <configfile>

    from the commandline.

  Macro replacements

    The primary use of preprocessor variables (aka attributes of `$ppp-
    '{'config'}>) is replacing patterns in the stream written to the output
    file. With `$c = $ppp-'{'config'}> in mind the typical patterns and
    their replacements are:

        ~~a~~               $c->{'a'}
        ~~b~~               $c->{'b'}
        ~~a->b~~            $c->{'a'}->{'b'}
        ~~a->e~~            $c->{'a'}->{'e'}



( run in 1.024 second using v1.01-cache-2.11-cpan-49f99fa48dc )