in reply to Re: Constants refferences
in thread Constants refferences

If you have a bareword between ${}, or a literal string, that's taken as the name of a variable ("${STRING}" is the same as "$STRING").

It appears to be more complicated than that:

use strict ; use warnings ; my $x = 57 ; print "\${x} = '", ${x}, "'\n" ; print "\${'x'} = '", ${'x'}, "'\n" ;
gives:
${x} = '57' Can't use string ("x") as a SCALAR ref while "strict refs" in use .. +.
Turning off "strict refs" gives:
${x} = '57' Use of uninitialized value in print ... ${'x'} = ''
Replacing my $x by our $x, gives:
${x} = '57' ${'x'} = '57'
The interpretation of the bareword case doesn't look desperately useful to me... Anybody know why Perl doesn't treat it as a subroutine/constant ?

Sadly, this wouldn't help "${CONSTANT}" but it would mean that @{REF_ARRAY_CONSTANT} would do what might be expected.

Replies are listed 'Best First'.
Re^3: Constants refferences
by Anonymous Monk on Aug 22, 2008 at 07:16 UTC
    Ambiguous use of ${x} resolved to $x at - line 4.