in reply to Count of split data

You should not use || because the statement will never fail if $filename is true, i.e., you're not checking the opening of $filename, just $filename. The lower precedence or is the best fit, unless you add parentheses:

open FILE, $filename or die $!;

Also, see the docs about indirect filehandles and 3-argument open.