#!/usr/bin/perl -w use strict; $|++; my(@PN, @GN); $/ = ".ENDS\n"; my @a; while( ) { my %seen; local $\ = "\n"; my @words = split / /, $_; for( @words ) { if( /VDD|VCC/ ) { print "Matched VDD $_\n"; push @PN, $_ unless $seen{Power}++; } elsif( /VSS|GND/ ) { print "Matched VSS $_\n"; push @GN, $_ unless $seen{GND}++; } } } print scalar @PN, "\n", scalar @GN, "\n"; __DATA__ .SUBCKT FOO X y Z .PININFO test VDD VDD VDD Vss vdd VSS t y foo blah blah bla .ENDS .SUBCKT test2 vdds VSS VDD .PININFO test2 2FS SEL blah blah blah .ENDS