in reply to Comparing HoH and HoHoH

Hi mikejones,

Not sure exactly which parts are giving you trouble, but note that "joe blow" is NOT how the uid, gid and gecos are being accessed.  "joe blow" is simply the value of the key gecos in the subhash.  The subhash is, itself, the value of the key jblow in the hash called $hash1.

Part of your confusion may be that you're mixing hashes with hash references; the topmost hash, $hash1, is a normal hash, since you're doing the equivalent of:

my %hash1 = ( ); # %hash1 is a normal hash (note the '%' prefix) $hash1{$name} -> {'uid'} = $uid; $hash1{$name} -> {'gid'} = $gid; $hash1{$name} -> {'gecos'} = $gecos;

rather than:

my $hash1 = { }; # $hash1 is a hash reference (note the '$' prefi +x) $hash1 -> {$name} -> {'uid'} = $uid; $hash1 -> {$name} -> {'gid'} = $gid; $hash1 -> {$name} -> {'gecos'} = $gecos;

But then the key 'jblow' has as its value a hash reference, where the -> notation is used.

In the case of:

$VAR1 = { 'jblow' => { '2195' => { 'gecos' => 'Joe Blow,,,', 'gid' => '20' } } };

you simply have another level deep, since the key '2195' has as its value a reference to another hash (that of { 'gecos' => 'Joe Blow,,,', 'gid' => '20' }) instead of a simple scalar.

You could even combine the two, and have:

$VAR1 = { 'jblow' => { 'uid' => '2195', 'gecos' => 'Joe Blow,,,', 'gid' => '20', '2195' => { 'gecos' => 'Joe Blow,,,', 'gid' => '20' } } };

s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Replies are listed 'Best First'.
Re^2: Comparing HoH and HoHoH
by mikejones (Scribe) on Jan 17, 2007 at 18:33 UTC
    Hello...no problem per say just trying to grasp these data structures. How to recognize them and the differences between them, how to use them effectively, and how to read them. thanks