in reply to Interpolate Perl variables in POD

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.

Replies are listed 'Best First'.
Re^2: Interpolate Perl variables in POD
by repellent (Priest) on Oct 01, 2008 at 01:12 UTC
    Upon writing a USAGE for a script, I would like for pod2usage to be updated dynamically as I maintain & update my code in the long term.

    A static USAGE means I would have to do manually update the POD when my code changes.

      I run a script from within my editor to generate 'man pages' from the POD in the current buffer.


      Perl reduces RSI - it saves typing
Re^2: Interpolate Perl variables in POD
by snoopy (Curate) on Oct 01, 2008 at 06:30 UTC
    Just as an aside. Embedded pod-like text in here-docs can accidentally be extracted from the source file as POD.

    This happens for me with the above code sample:

    714680(1) User Contributed Perl Documentation 7 +14680(1) Imaginary Interpolation This was defined previously: $my_perl_variable perl v5.8.8 2008&#8208;10&#8208;01 + 714680(1)