[Purdue-pm] interpolate perl variables in pod

Mark Senn mark at purdue.edu
Fri Dec 5 09:29:43 PST 2014


Another followup to Rick's message about sharing Perl
variable values in Perl and POD.

>From http://www.perlmonks.org/?node_id=714673

    As JavaFan and GrandFather have already mentioned, no, you can't
    directly. However, there's nothing to stop you from generating a POD
    document from a perl script:

    open (my $pod, '>', 'filename.pod') or die "Can't write pod file: $!";
    my $my_perl_variable = 'something';
    print $pod <<EOF;
    =head1 Imaginary Interpolation
    This was defined previously: C<$my_perl_variable>
    =cut
    EOF

    Of course, this would mean that you'd have to trigger the re-writing
    process somehow ... if you were to give an interface for updating
    whatever your variables were, you could regenerate the pod
    afterwards. I personally couldn't see the advantage of doing this,
    but I don't know what your full intentions are.

http://www.perlmonks.org/?node_id=714673 links to
    http://www.perlmonks.org/?node_id=515663
which has some more ideas.

http://www.perlmonks.org/?node_id=714673 also links to
    http://www.perlmonks.org/?node_id=48645
which didn't contain much usefil information in my opinion.

(Or, maybe just replace, for example ---VERSION---, in
a program.pl-replace file with sed to make a program.pl file.
This has the advantage if you want to sync version numbers
on multiple programs and/or docs without making any file changes.
I used this type of thing for a project I did years ago
and it worked out prettty well.)

-mark


More information about the Purdue-pm mailing list