Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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.

In reply to How to interpolate CONSTANTS in Here docs? by CoVAX

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (12)
    As of 2021-01-22 14:18 GMT
    Find Nodes?
      Voting Booth?