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$..$/

In reply to Re: Comparing HoH and HoHoH by liverpole
in thread Comparing HoH and HoHoH by mikejones

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.