sub getsub { my $sub = $_[0]; print "sub entered for $sub\n"; local $fh; seek $fh, 0, 0; while (<$fh>) { print if /\.subckt $sub/ .. /\.ends/; } }