RE: $p{"Bryan"}{"age"} = 31
- From: Bob_Showalter@xxxxxxxxxxxxxxx (Bob Showalter)
- Date: Tue, 31 May 2005 12:48:19 -0400
Bryan R Harris wrote:
> Is there anything wrong with out of the blue making a statement like
> this:
>
> $p{"Bryan"}{"age"} = 31;
That's fine, as long as $p{Bryan} doesn't exist or is already a hashref.
See: http://c2.com/cgi/wiki?AutoVivification.
For safety, be sure to "use strict" so you don't end up treating $p{Bryan}
as a soft reference:
$p{Bryan} = 'foo';
$p{Bryan}{age} = '31'; # this is like $foo{age} = 31
Also, the quotes are not strictly required.
>
> I thought perl required me to use the anonymous hash composer:
>
> $p{"Bryan"} = { "age" => 31 };
That's fine too, but not exactly equivalent.
.
- Prev by Date: Best WML editor for Perl?
- Next by Date: RE: A question about Win32:OLE
- Previous by thread: $p{"Bryan"}{"age"} = 31
- Index(es):
Relevant Pages
|