Dear Monks,
One way of making scalar read-only is to assign to glob the reference to constant scalar, e.g.
*PI = \3.14;
However, I have a problem with constructing read-only strings. If
*NAME = \"My name";
is marked read-only,
*NAME2 = \"My $name";
isn't.
Bigger snippet:
$bar = 'bar'; # This prints 'bar' *foo = \"The $bar is here"; $foo = "bar"; print "$foo\n"; # This dies *foo = \"The bar is here"; $foo = "bar2"; # error here print "$foo\n";
My question is: how to make "non-constant" strings (e.g. variables) become constant ones? Neither concatenation with '.', nor variable embedding in string works for me.
In reply to Constant string reference by przemo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |