However when I run the script only the last entity is printed from the last foreach loop. The problem seems to be that the %1 hash is overwritten by each successive match or something like that. I'm not sure. I thought what I did was ok output :open(VHD,"$vhd_file") || die "Can't open $vhd_file $!\n"; while(<VHD>){ # find all the entities in the current file if (/entity\s+(\w+)\s+is/i) { $1{'name'} = $1; $1{'fname'} = $vhd_file; push @entities, \%1; } if (/architecture (\w+) of (\w+) is/i ... /end $1\;/i) { # we are in the architecture of the entity. my $arch_entity = $2; # match instance_name : entity if (/^\s*(\w+)\s*:\s*(\w+)$/) { print STDOUT "$1\t$2\t$arch_entity\n"; # find the entity and add the deps to it foreach my $ent (@entities) { if ($$ent{'name'} eq $arch_entity) { $$ent{'deps'}{$2}++; } } } } } close VHD; } foreach my $ent (@entities) { print "$$ent{'fname'}\t$$ent{'name'}\n"; foreach my $dep (keys %{ $$ent{'deps'} } ) { print "DEP: $dep $$ent{'deps'}{$dep} "; print "\n"; } }
/proj/dice/external/adelante/24July2002/PowerBteFPGA/PBTE_FPGA/ref/coo +lrisc/status_816.vhd status_816 DEP: latchs_reg 34 DEP: pc_stack_816 11 DEP: latchr 367 DEP: latchr_reg 426 DEP: cr816lu 10 /proj/dice/external/adelante/24July2002/PowerBteFPGA/PBTE_FPGA/ref/coo +lrisc/status_816.vhd status_816 DEP: latchs_reg 34 DEP: pc_stack_816 11 DEP: latchr 367 DEP: latchr_reg 426 DEP: cr816lu 10 etc....
In reply to refs and hashes by diarmuid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |