in reply to string as ref ?!?!

It's documented exactly where you expect it be documented: in the manual page about references: man perlref.

Abigail

Replies are listed 'Best First'.
Re: Re: string as ref ?!?!
by powerman (Friar) on May 10, 2004 at 11:00 UTC
    Yeah, I've already realized what this is just symbolic reference... I've doublechecked `perldoc perlref`, and now, when I know what to search for I've found only one sentence about this issue: "Using a string or number as a reference produces a symbolic reference, as explained above.". And there in nothing more about this issue "above". :-( Anyway, I think a couple of examples like:
    "Test"->{qwe} = 111; "Test"->[1] = 222;
    will be nice to have in perlref...
      Examples from perlref dealing with symbolic references:
      $name = "foo"; $$name = 1; # Sets $foo ${$name} = 2; # Sets $foo ${$name x 2} = 3; # Sets $foofoo $name->[0] = 4; # Sets $foo[0] @$name = (); # Clears @foo &$name(); # Calls &foo() (as in Perl 4) $pack = "THAT"; ${"${pack}::$name"} = 5; # Sets $THAT::foo without eval

      Abigail

      I've already realized what this is just symbolic reference

      No, it isn't. A symbolic ref uses the string in the variable as the name of a package variable:

      my $f = "foo"; our $foo = "blah"; print $$f; __OUTPUT__ blah

      The behavior you're seeing in your example code is autovivification. You tell Perl that you want a hashref, so you get one. This behavior is forbidden by use strict 'refs'. For that, you should explicitly put a hashref into the variable, such as with my $var = { }; or  my $var = \%hash;.

      ----
      : () { :|:& };:

      Note: All code is untested, unless otherwise stated