Part of your question, though you didn't realize is, is how use constant works.

use constant creates a subroutine of no arguments for the constant you want, which returns the desired value. You COULD do the same manually.

sub FOO(?) {10;} sub BAR(?) {20;}

While it does work in expressions, FOO is not recognized as being a subroutine, when you use it in a string. While there are ways to make it be interpolated within a real string, which may or may not work in the fat-arrow string, the more modern solution is to use Readonly instead of <c.constant</c>. Readonly gives you real scalars, arrays, hashes which can't be modified.

use Readonly Readonly my $FOO => 10; Readonly my @GAMES => ( 'tennis', 'crocket', 'crazy eights' ); Readonly my %NUMBERS => ( consonents => [ qw( b c d f g h j k l m n p q r s t v w x z) +], vowels => [ qw( a e i o u y ) ], );

As Occam said: Entia non sunt multiplicanda praeter necessitatem.


In reply to Re: understanding this syntax by TomDLux
in thread understanding this syntax by Anonymous Monk

Title:
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, details, 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, summary, 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.