in reply to Setting a hash element to a anoymous hash
I believe when the following code executes:
if ( $i != 0 ) { $time{$previous} = { 'end_date' => $date, 'end_time' => $time }; }
it's overwriting the previously stored hashref. In other words, you're not appending the new information, but replacing the old. You could use something like this:
if ( $i != 0 ) { $time{$previous} = { %{$time{$previous}}, 'end_date' => $date, 'end_time' => $time }; }
to add the new information to the end. This will dereference the previous hashref before adding the new code.
Update Fixed the code to use an assignment. Also, see kvale's comment below.
|
|---|