The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Pod::Constants - Include constants from POD

SYNOPSIS

 use vars qw($myvar);
 use Pod::Constants -trim => 1,
     'Pod Section Name' => \$myvar;

 =head2 Pod Section Name

 This string will be loaded into $myvar

 =cut

DESCRIPTION

This module is for when you have constants in your code, but you want to keep them in the documentation so that when they change you only have to update them in one place.

Pod::Constants uses Pod::Parser to do the parsing of the source file. It has to open the source file it is called from, and does so directly either by lookup in %INC or from $0 if the caller is "main".

I have made this code only allow the "Pod Section Name" to match `head1', `head2' and `item' POD sections. If you have a good reason why you think it should match other POD sections, drop me a line and if I'm convinced I'll put it in the standard version.

AUTHOR

Sam Vilain, <sam@vilain.net>

BUGS/TODO

Is there any value in being able to import structured data from POD sections, perhaps? Maybe extracting tabular information into arrays or hashes?

What about doing nasty things to the caller's symbol table, so they don't need to "use vars"?