CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [ohgiap] extracting a .lib file-2: Edit Log



KevinR
Veteran


May 20, 2005, 12:18 PM


Views: 2195
Re: [ohgiap] extracting a .lib file-2

I assume that the table information is the first three lines after cell (AGLMII_IOST)


Code
cell (AGLMII_IOST) { 
...
...
...
timing_type : "three_state_enable"
timing_sense : "negative_unate"
cell_rise (delay_template7x7)
...
...


if there is more than one cell of 16 sets of tables then the flag ($h) would have to be reset. Here is one possible way:


Code
#!perl 
use strict;
use warnings;
use Data::Dump qw(dump);

open Infile, "C:/WINDOWS/Desktop/AGLMII_IOST_NOM.txt" or die $!;
#open Infile, "AGLMII_IOST_NOM.lib" or die $!;
my @data=<Infile>;
close(Infile);

my @AofH = ();
my ($i,$n,$f,$h) = (0,0,0,0);
for (@data) {
chomp;
($h++,$AofH[$i]{'timing_type'} = [strip_heading($_)]) if (index($_,'timing_type')>-1 && $h<3);
($h++,$AofH[$i]{'timing_sense'} = [strip_heading($_)]) if (index($_,'timing_sense')>-1 && $h<3);
($h++,$AofH[$i]{'cell_rise'} = [strip_heading($_)]) if (index($_,'cell_rise')>-1 && $h<3);
$AofH[$i]{'index_1'} = [strip($_)] if (/index_1/);
$AofH[$i]{'index_2'} = [strip($_)] if (/index_2/);
($n,$f)=(1,1) if (/values/);
push @{$AofH[$i]{'values'}},[strip($_)] if ($f == 1);
($f=0) if (/;/);
($i++,$n=0) if ($n == 1 && $f == 0);
}

sub strip {
local $_ = shift;
s/index_\d//;
tr/,0-9.//cd;
return(split(/,/));
}
sub strip_heading {
local $_ = shift;
tr/;{"//d;
s/^\s+//;
s/\s+$//;
s/\s+/ /g;
return($_);
}
print dump(@AofH);

-------------------------------------------------


(This post was edited by KevinR on May 22, 2005, 10:49 PM)


Edit Log:
Post edited by KevinR (Veteran) on May 22, 2005, 10:49 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives