Malcolm on 20 Jan 2011 11:55:44 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] perl question


On 1/20/2011 2:44 PM, Eric at Lucii.org wrote:

Those that do look like this example which would be something like $output[5]:
$VAR1 = {
           '128' =>  {
                      'salutation' =>  'Dr.',
                      'area' =>  '800',
                      'spec_link' =>  '131',
                      'state' =>  'PA',
                      'last_name' =>  'Smith',
                      'dr_id' =>  '1',
                      'city' =>  'Swarthmore',
                      'middle' =>  'A',
                      'active' =>  undef,
                      'phone' =>  '555-1212',
                      'description' =>  'some description goes here',
                      'sex' =>  'M',
                      'address2' =>  '',
                      'loc_no' =>  '1',
                      'zip' =>  '19067',
                      'title' =>  'DMD',
                      'address1' =>  '123 Any Street.',
                      'first_name' =>  'John'
                    }
         };

... but perl barfs on the use of keys
Type of arg 1 to keys must be hash (not array element) at ./build_fast_doc.pl
line 229, near "]  ;"

What am I missing here?  I thought the array elements here ARE hashes.

It looks like they are hash-refs, not hashes. You need to tell perl what type of thing the ref points to. Something like:

keys %{ $output[$x] }
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug