There are several ways to open files in Perl and it seems that there are many opinions on the best way to do so. I've looked into it a bit and I believe that I'm going to use the three-argument version of open going forward.
open (my $filename_fh, '<', $filename);
As stated in the linked page, benefits include:
- Perl will open files even if they contain file operation (< > |) characters
- The scalar file handle ends in _fh so it should be obvious it is a file handle everywhere
- The file handle should be meaningful
- The file handle will be cleaned up automatically if it goes out of scope