needed help getting getoption::long to perform a command

P

perl_newbie

I still have some problems implementing the getoption::long to retire
unused cells. I believe the 'help' option is okay now but I need more
help. I have posted the smallest program possible that can to
demonstrate output.
Will you please help me figure out how to use the -unused option to
push it to another file to later run it to remove the unused cell from
the cad tree?
Can you also help to reference my $hierc->{$cell} into my
subroutine? I have tried several ways to reference the hash which
contains my library to compare it to the cad tree libraries the cell is
found in but had no luck doing so

Desire output with no option chosen:
list to dump: cell1A
list to dump: cell4a
library mismatch in cell4 (gold:lib3,cad:lib4)

Desired output with "-unused" option chosen to be run later in time:
dssc retire cell1A
dssc retire cell4a

Current ouput with code below and no options chosen:
% perl dup.cell gold cad
list to dump: cell1A
list to dump: cell4a
--input files--
lib0 cell1
lib1 cell2
lib2 cell3
lib3 cell4
lib4 cell5
gold (END)

lib0 cell1
lib0 cell1A --to be marked for deletion
lib1 cell2
lib3 cell4
lib3 cell4a --to be marked for deletion;
lib4 cell4 --to be marked for deletion; found in wrong lib
lib4 cell5

--my code---
#!usr/bin/perl -w
use strict;
use Data::Dumper;

my $show_file={};
my $hierec={};
my $cell={};
my $lib={};
my $cadcell={};
my $cadlib={};
my @cell=();
my ($opt_help,$opt_unused);
#------------------------------------------------------------------------
use Getopt::Long; #for getting right arguments on the command line

if (! & GetOptions('help'=>\$opt_help, 'unused'=>\$opt_unused))
{ print"Invalid Flag. please try -help.\n";exit;}

if (@ARGV == 2 )
{
my $list1=$ARGV[0];
my $list2=$ARGV[1];

open(L1,"<$list1") || die "cannot open Gold STND file";
open(L2,"<$list2") || die "cannot open Cadence file";
}
if ($opt_help) {
print("\tFlag_options include:\n");
print("\t\t-help\n");
print("\t\t-unused\n");
exit if defined $opt_help;
}
if ($opt_unused){
print("dssc -retire {$cadcell}\n");
}

while(<L1>)
{
$show_file=$_;
if ($show_file=~/^\s?(\S+)\s+(\S+)/)
{
my ( $cell, $lib)= ($2, $1);
$hierec->{$cell}->{$lib}=1;
}
}
&comp_2_cell_list;
sub comp_2_cell_list
{
foreach(<L2>)
{
if(~/^\s?(\S+)\s+(\S+)/)
{

my ($cadlib,$cadcell)=($1,$2);
if(! exists($hierec->{$cadcell}))
{
print "list to dump: $cadcell\n";
}
# unless ( exists $hierec->{$cell}->{$cadlib}) #problem
referencing $libs
# {
# print "mismatch libs in:$hierec ($hierec->{$cell},$cadlib)\n";

# print Dumper($hierec->{$lib});
# }
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top