In your adding lines you add entries line [ $entry ], which means, make an array reference (the brackets) which has $entry as the first element of the array. You then have a hash of hashes of arrays (for at least some entries). If you meant the arrays, you'll have to add a third loop to the printing code to account for that level of nesting. If you didn't intend to make arrays there, just drop those brackets.
James Gray On Monday, September 30, 2002, at 02:59 PM, Ken Hammer wrote: > > From a previous post I needed to identify > a particular data structure. It is a hash of hashes. > Now, I need to print the hash out. > I'm using the code from the "Programing > Perl" 3rd edition from O'Reilly on how > to print out the hash and of course I'm > having a problem. > > This is from Chapter 9, page 281 slighly > changed to reflect my values: > > for $table ( keys %tablename) { > print "Table Name: $table \n"; > > for $items ( keys %{ $tablename{$table} } ) { > print "\t$items=$tablename{$table}{$items}\n "; > > } > > print "\n"; > > Here are the results: > > Table Name: TURBINE_PERMISSION > con_name=ARRAY(0x216de8) > index_name=TURBINE_PERMISSION_PK > con_type=ARRAY(0x216c8c) > columns=PERMISSION_ID > created_by=ARRAY(0x211a50) > type=NORMAL > rem_con_name=ARRAY(0x211b04) > tablespace=CTNG > > This is the code that created the hash of hashes. > It was done in 2 parts: > > First part (initilizing): > > $tablename{"$table"} = { > "index_name" => $index_name, > "columns" => @column_name, > "type" => $index_type, > "tablespace" => $tablespace_name > > }; > > Adding to the hash: > > $tablename{$table} -> {con_name} = [$constraint_name]; > $tablename{$table} -> {con_type} = [$type]; > $tablename{$table} -> {rem_con_name} = [$r_constraint_name]; > $tablename{$table} -> {created_by} = [$generated]; > > The above is from the help (thank you) from a previous post. > > Why am I getting the value in the first part, and the > memory location for the second part? In other words, the key/values > print out as expected from the initializing loop, but not from > the "adding" part? > > -- > Ken Hammer > University Of Michigan > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]