------------------------------------------------
On Thu, 23 Jan 2003 14:59:07 -0500, Ed Sickafus <[EMAIL PROTECTED]> wrote:

>  -- Back to square one?
> 

I think you are still having problems with the notion of what the key is and what the 
value is....

> # I define 3 variables  ...
> 
>   $TS = time();
>   $LN = "Washington";                         # test value
>   $CN = "Costa Rica";                         #  "     "
> 

OK, so $TS now contains the current time...which I think is what you want your outer 
hash key to be...correct me if I am wrong?

> # ... in order to build a HoH ...
> 
>   $newH{'TS'}         => $TS;         # TS is the outer key.   <<== line 33

This sets the outer hash key to the string 'TS' and gives it the value of the time 
($TS) from above.


> 
> # ... using this code ...
> 
>   %newH       =  (
>          TS   => {                                    # Note outer hash key, TS
>                  'LN' => $LN,         # Last Name
>                  'CN' => $CN,         # Country
>                  },
>          );
> 

Now you have *reset* the value of the 'TS' key of the hash to an anonymous hash 
reference, overwriting your earlier value (that is the time stamp is now gone).

Lets say....

$TS = time();
$LN = 'dAnconia';
$CN = 'USA';

now, we want:

$newH{$TS} = { 'LN' => $LN, 'CN' => $CN };

This sets the 'outer key' to be the time stamp (sort of better written directly)

$newH{time()} = { 'LN' => $LN, 'CN' => $CN };

foreach my $timestamp (sort(keys(%newH))) {
   print "$timestamp  Last Name = " . $newH->{$timestamp}->{'LN'};
   print "Country = " . $newH->{$timestamp}->{'CN'};
}

Does this make sense, help? Keep posting, we will get it there, even if it kills one 
of us ;-).

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to