I\'ve got two questions about the Perl open function:
1) I seem to remember from Perl Best Practices that the 3-argument version of open<
One aspect to keep in mind is that the two-arg form is broken. Consider a file named ' abc' (that is, a file name with a leading blank). You cannot open the file:
open my $foo, ' abc' or die $!;
open my $foo, '< abc' or die $!;
open my $foo, '< abc' or die $!;
# nothing works
The space gets dropped and so the file can no longer be found. Such a scenario is highly improbable, but definitely a problem. The three-arg form is immune to this:
open my $foo, '<', ' abc' or die $!;
# works
This thread from perlmonks is as good a discussion as any of the issue. Just bear in mind that in 2001, the three-arg form was still considered new, and thus not suitable for portable code, since Perl programs would die with a syntax error if run on a 5.005 interpreter. This is no longer the case: perl 5.005 is beyond deprecated, it is obsolete.