Always use 3-argument open

open utf8

Always use open my $fh, '<:encoding(utf8)', $filename or die ..., the 3-argument version of open, and never the old way.

Note the open call has 3 parameters:

  1. The holder of the file-handle which has been just created. open will assign the file-handle to it.

  2. The mode of open. (to read, to write, to append, etc.)

  3. Supply the encoding (utf8 in our case).

  4. Path to the file.

Comment to the experts

In the rare cases when you must use the old version, you'll know it.

Other pages

readline() on closed filehandle in Perl
open a file in Perl
Three-argument form of open used and it is not available until perl 5.6.
Perl Critic reports
Finish Perl::Critic cleanup, set up Test::Perl::Critic

Author

Gabor Szabo (szabgab) Gabor Szabo