analyse_db - a Perl module to analyse databases parsed with parse_db
use parse_db;
use analyse_db;
my $r_records= parse_db::parse_file($my_db_file);
analyse_db::add_link_info($r_records);
print "references: ",
join("\n",references_list($r_records,"myrec")),"\n";
This module contains functions that analyse a database that was parsed with parse_db.
rec_link_fields()
my $r_h= analyse_db::rec_link_fields($recs, $recname);
This function returns a reference to a hash that contains field-value pairs. The values are lists containing of the name of the other record, the referenced field and following flags (e.g. "CPP" or "NMS"). The first parameter is the structure created by parse_db::parse(), the second parameter is the name of the record.
add_link_info()
analyse_db::add_link_info($records);
This function adds information about the connections of records to the records datastructure. The $records
datastructure is a reference to a hash. Each key is a record name that points to another hash-reference. This structure is described in the documentation of the perl module parse_db. The function add_link_info adds a new key, "LINKS" to each record hash. It points to another hash-reference with the keys "REFERENCES" and "REFERENCED_BY". These contain hashes that show which records are connected with this one.
Here is a short example (note that parse_db::dump() has almost the same function as Data::Dumper):
use Data::Dumper;
use parse_db;
use analyse_db;
my $records= parse_db::parse_file("idcp13.db");
analyse_db::add_link_info($records);
print Dumper($records->{"UE112ID7R:AdiVDrvDstSet"})
The now output shows this:
$VAR1 = {
'LINKS' => {
'REFERENCES' => {
'UE112ID7R:AdiUnVDrvDstICnt' => 'FLNK:VAL'
},
'REFERENCED_BY' => {
'UE112ID7R:AdiUnVDrvDstC' => 1,
'UE112ID7R:DiagResetBrakes' => 1,
'UE112ID7R:BaseParGapselO' => 1,
'UE112ID7R:AdiVDrvDmo' => 1
}
},
'TYPE' => 'longin',
'FIELDS' => {
'DESC' => 'adivhdst_ins.pyx',
'FLNK' => 'UE112ID7R:AdiUnVDrvDstICnt.VAL '
}
}
The record 'UE112ID7R:AdiVDrvDstSet' is referenced by "UE112ID7R:AdiVDrvDstSetC", "UE112ID7R:DiagResetBrakes", "UE112ID7R:BaseParGapselO" and "UE112ID7R:AdiVDrvDmo". The record 'UE112ID7R:AdiVDrvDstSet' itself references "UE112ID7R:AdiUnVDrvDstICnt.VAL" with field "FLNK".
references_list()
print join("\n",analyse_db::references_list($records,$my_recname)),"\n";
This function returns a list of records that is referenced by the given record.
referenced_by_list()
print join("\n",analyse_db::referenced_by_list($records,$my_recname)),"\n";
This function returns a list of records that reference the given record.
linkset_hash()
my $r_h= linkset_hash($records,$r_recnames,$maxlevel)
This function returns a hash-reference containing all records that are related to the records given in the list reference $r_recnames. $maxlevel is the maxmum allowed distance. The hash-value is the minimum distance to one of the records given in $r_recnames. Example:
{ "RECORD_START" => 0,
"RECORDA" => 1,
"RECORDB" => 2,
}
In this example RECOORD_START is the record itself (level0), RECORDA has a distance of 1 (level 1), RECORDB has a distance of 2 (level 2).
rem_capfast_defaults()
rem_capfast_defaults($records)
This function removes all fields that have the still their default value as it is defined in capfast.
Goetz Pfeiffer, Goetz.Pfeiffer@helmholtz-berlin.de
perl-documentation