#!/usr/bin/perl { local $/ = "INPUT SEQUENCE="; <>; # discard first chunk while(<>) { chomp; open O, '>', /^(\d+)/ and $1 or die "$!\n"; print O $/,$_; } } #### #!/usr/bin/perl { my $file = 'File00000'; local $/ = "INPUT SEQUENCE="; <>; while(<>) { chomp; unless ($.-2 % 1000) { open O, '>', ++$file or die "cant write '$file': $!\n"; } print O $/,$_; } }