http://qs321.pair.com?node_id=761580


in reply to pattern matching to separate data

This looks like homework to me so I'll make suggestions rather than code

1) Filehandles can be stored in variables too:

my ($fh1, $fh2); open $fh1, ">GENEID.out" or ... open $fh2, ">PROTID.out" or ...

2) Read every line - print every line. You are obviously not doing that.

3) set another Filehandle var '$fh' with the appropriate Filehandle as you detect a change and use your new $fh to store and print to the right file.