Ken Hammer wrote:
>
> A strange question.
>
> I'm using the following data structure to
> store information from a data base query:
>
> $tablename{"$table"} = {
> "table_name" => ["$table"],
> "index_name" => ["$index_name"],
> "columns" => ["@column_name"],
> "type" => ["$index_type"],
> "tablespace" => ["$tablespace_name"]
>
> This works great
Are you sure? None of the quotation marks are required and the ones
around the array are changing the array to a space separated scalar.
$tablename{$table} = {
table_name => [ $table ],
index_name => [ $index_name ],
columns => [ @column_name ],
type => [ $index_type ],
tablespace => [ $tablespace_name ]
> and I can later extract the info
> from this structure.
$table_name = $tablename{$table}{'table_name'}[0];
$index_name = $tablename{$table}{'index_name'}[0];
@column_names = @{$tablename{$table}{'index_name'}};
$index_type = $tablename{$table}{'type'}[0];
$space_name = $tablename{$table}{'tablespace'}[0];
Read up on data structures and references:
perldoc perldata
perldoc perldsc
perldoc perllol
perldoc perlref
> I have 2 questions. What type of
> structure is this
A Hash of Hashes of Arrays
> and how do I add to it?
$tablename{$table}{'table_name'}[0] = $table_name;
$tablename{$table}{'index_name'}[0] = $index_name;
@{$tablename{$table}{'index_name'}} = @column_names;
$tablename{$table}{'type'}[0] = $index_type;
$tablename{$table}{'tablespace'}[0] = $space_name;
> When I try to add more info from a subsequent query like
> this:
>
> $tablename{$table} = {
> "con_name" => ["$constraint_name"],
> "con_type" => ["$type"],
> "rem_con_name" => ["$r_constraint_name"],
> "created_by" => ["$generated"]
> };
>
> I lose all the previous information, so that only the above
> is now stored.
> What have I done, how do I do what I want, and am I in over my head?
$tablename{$table}{'con_name'} = [ $constraint_name ];
$tablename{$table}{'con_type'} = [ $type ];
$tablename{$table}{'rem_con_name'} = [ $r_constraint_name ];
$tablename{$table}{'created_by'} = [ $generated ];
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]