I've created a complex, nested data structure that is, at its outermost level, a hash: %qa. It collects QA statistics for a school.

Now I want to be able to process multiple schools in one run, so I've created another hash, %sch_qa, whose key is School Name and whose value is a ref to *a copy of* %qa.

Assuming $sch_name is the name of the school, I wrote this:

if ( ! exists $sch_qa{$sch_name} )  {
        %{$sch_qa{$sch_name}} = %qa;
}

That seemed to execute okay. At the end, however, when I dumped %sch_qa it looked pretty strange. Actually, the first entry looks somewhat normal. It's the last three that are weird: they all seem to recursively refer to this entire hash.

Am I duplicating the original %qa hash correctly?

Thanks for any help!
Chap

$VAR1 = {
          '173' => {
                     'M_Admins' => {
                                     'SchoolID' => {
                                                     'notnull' => []
                                                   },
                                     'first_name' => {
                                                       'notnull' => []
                                                     },
                                     'last_name' => {
                                                      'notnull' => [],
                                                      'alpha' => []
                                                    }
                                   },
                     'M_Discipline' => {
                                         'Student_Number' => {
'notnull' => []
                                                             },
                                         'Consequence' => {
'histo' => [
                                                                         {
'011 ' => 4, '002 ' => 83, '' = > 60, '081 ' => 1, 'XRD ' => 235, 'XTO ' => 60, '022 ' => 12, '004 ' => 16,
                                                                         }
                                                                       ]
                                                          },
                                         'Last_Name' => {
'notnull' => []
                                                        },
                                         'SchoolID' => {
'constant' => [
                                                                         10114
                                                                       ]
                                                       },
                                         'First_Name' => {
'notnull' => []
                                                         },
                                         'Category' => {
                                                         'histo' => [
                                                                      {
'' = > 13802
                                                                      }
                                                                    ]
                                                       }
                                       },
                     'M_Historical_Grades' => {
                                                'Storecode' => {
'histo' => [
                                                                              {
'S1 ' => 7090, 'YR ' => 12548, 'S2 ' => 3783, '2007 -2' => 7, 'SS ' => 126
                                                                              }
                                                                            ]
                                                               },
                                                'Termid' => {
'histo' => [
                                                                           {
'1200 ' => 37, '1700 ' => 9370, '1500 ' => 2518, '1600 ' => 5706, '1800 ' => 3517, '1000 ' => 12, '1400 ' => 2318, '1300 ' => 43, '1100 ' => 33
                                                                           }
                                                                         ]
                                                            }
                                              }
                   },
          '2050' => {
                      'M_Admins' => $VAR1->{'173'}{'M_Admins'},
                      'M_Discipline' => $VAR1->{'173'}{'M_Discipline'},
'M_Historical_Grades' => $VAR1->{'173'} {'M_Historical_Grades'}
                    },
          '5050' => {
                      'M_Admins' => $VAR1->{'173'}{'M_Admins'},
                      'M_Discipline' => $VAR1->{'173'}{'M_Discipline'},
'M_Historical_Grades' => $VAR1->{'173'} {'M_Historical_Grades'}
                    },
          '273' => {
                     'M_Admins' => $VAR1->{'173'}{'M_Admins'},
                     'M_Discipline' => $VAR1->{'173'}{'M_Discipline'},
'M_Historical_Grades' => $VAR1->{'173'} {'M_Historical_Grades'}
                   }
        };


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to