needed help getting getoption::long to perform a command

Discussion in 'Perl Misc' started by perl_newbie, Jun 2, 2005.

  1. perl_newbie

    perl_newbie Guest

    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});
    # }
    }
    }
    }
     
    perl_newbie, Jun 2, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    691
    Eric Sosman
    Jul 8, 2003
  2. Mike Hofer
    Replies:
    1
    Views:
    405
  3. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,205
    Peter Shaggy Haywood
    Sep 20, 2005
  4. Mathieu Dutour

    long long and long

    Mathieu Dutour, Jul 17, 2007, in forum: C Programming
    Replies:
    4
    Views:
    486
    santosh
    Jul 24, 2007
  5. Daniel Bretoi

    getoption long question

    Daniel Bretoi, Oct 29, 2003, in forum: Ruby
    Replies:
    4
    Views:
    96
    Mark Wilson
    Oct 29, 2003
Loading...

Share This Page