M
monte
hi, I am at it again and so I got a new question.
please assume that the files are correct and not empty. the format of
the files are as follows:
lib0 cell1
lib2 cell2
lib3 cell4
lib5 cell5
etc...
1)I'd like to use a previous hash with the keys=>$cells found in the
main. however, when I try passing it to the subroutine, it complains of
explicit package.
2)turned off strict to check the contents of the hash in the subroutine
but it is empty, how can I bring it and compare to the newly parse
cells to be check?
CODE:
---------------------------------------------------------
#!usr/bin/intel/perl -w
# prog to report duplicate cells found in the heirarchy
# format: level lib cell view
#use strict;
#%main::rec();
my $show_file={};
my $rec={};
my $cell={};
my $lib={};
my @dump=();
my @cell=();
my $cadcell=();
#------------------------------------------------------------------
#file to output cells found in different libraries
my $file = "/tmp/perl/rec.err";
open(ERR ,">$file") || die "cannot open new file: $!\n";
#file contains possible bad cells, but not all.format:<lib> <cell>
my $tfile = "/tmp/perl/fake.ls";
open(BADCELLIST,"<$tfile") || die "cannot open new file: $!\n";
#-----------------------------------------------------------------
#parsing the GOOD file of cells from command line(source of cells)
while(<>)
{
$show_file=$_;
#print $show_file;
if ($show_file=~/^\S+\s+\d\.\s+(\S+)\s+(\S+)/ ||
$show_file=~/^\d\.\s+(\S+)\s+(\S+)/)
{
my ( $cell, $lib)= ($2, $1);
$rec->{$cell}->{$lib}=1;
#making the cell & lib to exist as a hash later to be used as error
finder and for comparing to $cadcells found in my directory
}
}
#&error_check;
#----------------------------------------------------------
#made easier to read by assigning a variable. interested in finding
$cells in different lib for error checking
sub error_check
{
foreach my $cell (keys %$rec)
{
my @contents = sort keys %{ $rec->{ $cell } };
if (@contents == 1)
{
print "$cell (@contents)\n";
}
if( @contents >1 )
{
print ERR "$cell (@contents) -error?";
}
}
}
#----------------------------------------------------------------
# HELP!!!!! here is where the I'd like to use the previous $rec with my
$cell as the key to compare to the new $cadcell in order to find the
ones that do not exits and dump them.
#problem is that I cannot sucessfully pass the previous $rec with
keys=>$cell to compare it to new cadcells!
&comp_2_cell_list;
sub comp_2_cell_list
{
foreach(<BADCELLIST>)
{
if(~/^\s?\S+\s+(\S+)/)
{
my $cadcell=$1;
if(! exists($rec{$cadcell}))
{
# push(@dump,$cadcell,"\n");
# print @dump;
print " the real thing:$rec{$cadcell}\n"; #problem here, it is
empty???
}
}
}
}
please assume that the files are correct and not empty. the format of
the files are as follows:
lib0 cell1
lib2 cell2
lib3 cell4
lib5 cell5
etc...
1)I'd like to use a previous hash with the keys=>$cells found in the
main. however, when I try passing it to the subroutine, it complains of
explicit package.
2)turned off strict to check the contents of the hash in the subroutine
but it is empty, how can I bring it and compare to the newly parse
cells to be check?
CODE:
---------------------------------------------------------
#!usr/bin/intel/perl -w
# prog to report duplicate cells found in the heirarchy
# format: level lib cell view
#use strict;
#%main::rec();
my $show_file={};
my $rec={};
my $cell={};
my $lib={};
my @dump=();
my @cell=();
my $cadcell=();
#------------------------------------------------------------------
#file to output cells found in different libraries
my $file = "/tmp/perl/rec.err";
open(ERR ,">$file") || die "cannot open new file: $!\n";
#file contains possible bad cells, but not all.format:<lib> <cell>
my $tfile = "/tmp/perl/fake.ls";
open(BADCELLIST,"<$tfile") || die "cannot open new file: $!\n";
#-----------------------------------------------------------------
#parsing the GOOD file of cells from command line(source of cells)
while(<>)
{
$show_file=$_;
#print $show_file;
if ($show_file=~/^\S+\s+\d\.\s+(\S+)\s+(\S+)/ ||
$show_file=~/^\d\.\s+(\S+)\s+(\S+)/)
{
my ( $cell, $lib)= ($2, $1);
$rec->{$cell}->{$lib}=1;
#making the cell & lib to exist as a hash later to be used as error
finder and for comparing to $cadcells found in my directory
}
}
#&error_check;
#----------------------------------------------------------
#made easier to read by assigning a variable. interested in finding
$cells in different lib for error checking
sub error_check
{
foreach my $cell (keys %$rec)
{
my @contents = sort keys %{ $rec->{ $cell } };
if (@contents == 1)
{
print "$cell (@contents)\n";
}
if( @contents >1 )
{
print ERR "$cell (@contents) -error?";
}
}
}
#----------------------------------------------------------------
# HELP!!!!! here is where the I'd like to use the previous $rec with my
$cell as the key to compare to the new $cadcell in order to find the
ones that do not exits and dump them.
#problem is that I cannot sucessfully pass the previous $rec with
keys=>$cell to compare it to new cadcells!
&comp_2_cell_list;
sub comp_2_cell_list
{
foreach(<BADCELLIST>)
{
if(~/^\s?\S+\s+(\S+)/)
{
my $cadcell=$1;
if(! exists($rec{$cadcell}))
{
# push(@dump,$cadcell,"\n");
# print @dump;
print " the real thing:$rec{$cadcell}\n"; #problem here, it is
empty???
}
}
}
}