Re: UPDATE2:

I can't see what's confusing you about \"1" resulting in a SCALAR - I remember reading somewhere, I think it's in one of the O'Reillys, but senility and alcohol together combine to prevent me from remembering exactly where, that a primitive means of constructing a constant relies on this - using idioms of the form:

*PI = \3.14159; *STR = \'Some string'; # etc.
Soooo, AFAICT, pre-declaring the literal as a constant solves your problem...
use warnings; use strict; no strict qw/vars/; *STR = \'Some string'; my ($str1, $str2) = (\'Some string', $STR); sub foo(\$) { return } eval { foo($STR) }; warn "$@"; eval { foo($str1) }; warn "$@"; eval { foo($str2) }; warn "$@";
Giving
$ perl tst.pl Warning: something's wrong at tst.pl line 10. Warning: something's wrong at tst.pl line 12. Warning: something's wrong at tst.pl line 14.
Doesn't it ?

A user level that continues to overstate my experience :-))

In reply to Re: Prototype for constant items??? by Bloodnok
in thread Prototype for constant items??? by LanX

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.