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:
Soooo, AFAICT, pre-declaring the literal as a constant solves your problem...*PI = \3.14159; *STR = \'Some string'; # etc.
Givinguse 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 "$@";
Doesn't it ?$ 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.
In reply to Re: Prototype for constant items???
by Bloodnok
in thread Prototype for constant items???
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |