in reply to SCALAR output instead of attribute name.
The name of a variable can be used as a "soft reference" (only when the referent is a symbol table variable and only when in no strict 'refs'). But think of it, not all scalar values even have names, and some have many! Because of this, taking a reference to any variable using the backslash operator creates a special "hard reference" scalar. When you print out something of this reference type, you get SCALAR(0x81717c4) (if the referent is a normal scalar). Perhaps consult perlreftut for more detailed info?
A better way to fill your hash the way you want is like this:
Again, you'll need an explicit list of keys for the hash, as you can't extract the attribute names from the variables.my @fields = qw/nam pwd uid gid dsc hom shl/; while (<F>) { my %attrs; @attrs{@fields} = split /:/, $_; $password->{ $attrs{nam} } = \%attrs; }
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: SCALAR output instead of attribute name.
by sschneid (Deacon) on Dec 18, 2003 at 18:41 UTC |