_checksum relates to which columns make up the index. ie col 0 is 1, col 1 is 2, col 3 is 4, col 1+3 is 5 etc.1) holds the basic table data %T{tableName}=[['A','B',undef,'C'],['1','2',undef,'3'],['1','2',undef, +'67']]; 2) hold the column names for each table %C{tableName}={ 'serialno' => 0, 'type' => 1, 'hardware' => 2, 'software' => 3, }); 3) holds any required indexes %I{tableName}{_checksum}{'A'}=ref_to_row ['A','B',undef,'C'] %I{tableName}{_checksum}{'1'}=ref_to_row ['1','2',undef,'3']
This works ok but I would like to find a way of NOT having to state the tableName within the loop in the call to getColumn. After all the $row is part of the table so something likeforeach $row (@{getTable(tableName}) # getTable() returns the ref f +rom $T{tableName}; { $row->[getColumn(tableName,'software']='updated'; # getColumn() + simply returns the result of $C{tableName}{colName} }
2) mentioned OO above but I have not really used it with Perl. I'm looking into rewriting and I think it will work quite well but I'm having problems seeing how to relate tables and rows. I can bless a table into being which would contain column names and indexes. Do I make the rows sub-objects of the table ? Any ideas on how to do this so that from any given row we can find which table it is in. if all rows are objects then how do we loop through every object in a class ?foreach $row (@{getTable(tableName}) # getTable() returns the ref f +rom $T{tableName}; { $row->column('software'); # using OO in some way ? or element($row,'software) # not so good - uses a hash of row +reference addresses to enable me to find which table any row is in }
In reply to table ideas/comments by wertert
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |