$/ = ">#W#"; my $count = 0 ; while(){ $count++ if (m/>/g) ; $/="\n"; while(){} $/=">#W#"; } $/="\n";