On 2/3/10 Wed  Feb 3, 2010  6:44 AM, "PolyPusher"
<eric.d.fitzsimm...@gmail.com> scribbled:

> Hi All,
> 
> I have some Perl experience but has been awhile.   I mainly write
> SKILL lisp programs for Cadence CAD for a layout group(we are a IC
> design center).
> 
> I have a CBR(describes circuit) file and want to open it, find the
> line in file
> 
> .SUBCKT __RE1321_4 HB_GND GSM_RX DCS_RX DCS_VRX GSM_VRX PCS_TX
> SHUNT_GND ANT
> +    VRXEN GSM_VTX GSM_TX PCS_VTX
> 
> Where .SUBCKT __RE1321_4 is found and the output of the file is the
> pins(ignore the + sign)
> 
> Output:
> ("HB_GND" "GSM_RX" "DCS_RX" "DCS_VRX" "The rest of 'em")
> 
> The above is a list that can be used by SKILL code.
> 
> I only understand the very basics of perl, the more info the better.
> 
> Thank you in advance for any help,
> Eric
> 
> What I have so far.....

You have a good start. My additions below are untested, so may contain bugs.

> 
> #!/usr/bin/perl
> use warnings;
> use strict;
> 
> 
> my $read_file  = 'RE1321_4.cbr';
> my $write_file = 'NavInputPins.list';
> 
> 
> open READ,  '<', $read_file  or die "Can't open '$read_file' $!";
> open WRITE, '>', $write_file or die "Can't open '$write_file' $!";
> 

while( my $line = <READ> ) {
    if( $line =~ m{ \A \.SUBCKT }x ) {
        my @fields = split(' ',$line);
        my @pins = grep( !/\+/, @fields[ 2 .. $#fields] );
        print WRITE '"', join('" "',@pins), "\"\n";
    }
> }
> 
> 
> close READ  or die "Couldn't close '$read_file' $!";
> close WRITE or die "Couldn't close '$write_file' $!";
> 
> exit 0;
> 
> 
> __END__
> 



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to