http://www.perlmonks.org?node_id=1116399

CoVAX has asked for the wisdom of the Perl Monks concerning the following question:

I have some constants (defined with `use constant`) that I am desirous of using in a `here` doc. However no interpolation occurs, so the strings naming the constants literally appear instead of their values.

What I have resorted to is: assigning variables the values of the constants, and using the variable names in the here doc. Is there a better way to accomplish the desired behavior?

use constant { OUT_DIR => 'out', OUT_FIELDSEP => '=', OUT_FILENAME => 'ks', OUT_SUFXSTOR => 'storable', VAL_MIN => 15, VAL_MAX => 3600, };

This does not work as intended:

print <<USAGE; This program does this and that with the OUT_DIR. The filename is OUT_FILENAME and the file suffix is OUT_SUFXSTOR. Fields are separated with the OUT_FIELDSEP character. Enter a value between VAL_MIN and VAL_MAX. USAGE

What I've resort to doing:

my $out_dir = OUT_DIR; my $out_fs = OUT_FIELDSEP; my $out_fn = OUT_FILENAME; my $out_sx = OUT_SUFXSTOR; my $valmin = VAL_MIN; my $valmax = VAL_MAX; print <<USAGE; This program does this and that with the $out_dir. The filename is $out_fn and the file suffix is $out_sx. Fields are separated with the $out_fs character. Enter a value between $valmin and $valmax. USAGE
Searched for donuts and crumpit. Found content instead.