in reply to Determining new file

Use function eof:
eof(); # Return 1 for EOF for last file in your list eof; # Return 1 for EOF for each file from your list
It's 'magic' property of this function.
--------> SV* sv_bless(SV* sv, HV* stash);