#!/usr/bin/perl use strict; use warnings; my $words = 0; while () { next unless /^\.SUBCKT /; #my @wds = splice([split(/[^\w.]+/)],2); (lieber nicht so, siehe Hinweis von Linuxer!) my @wds = split(/[^\w.]+/); @wds = splice(@wds,2); next unless @wds; print join "; ", @wds; print "\n"; $words += scalar(@wds); } print("words=$words\n"); __DATA__ .SUBCKT D1N4148 Anode1 Kathode1 foo .SUBCKT D1N4248 Anode2 Kathode2 foo bar .SUBCKT D1N4348 Anode3 Kathode3 .UBCKT D1N4448 Anode4 Kathode4 foo SUBCKT D1N4548 Anode5 Kathode5 foo bar .SUBCKTa D1N4648 Anode6 Kathode6 .SUBCKT D1N4748 .SUBCKT .SUBCKT D1N4948 Anode9 Kathode9