You shouldn't read whole file (especially if you know that it is very big). You run out of free memory. Instead reading the whole file it would be better read it line by line (or even more better by some number of lines).

The main reason (and possibly the only reason) for using the 3 arg form is to have a clear separation between the mode and the expression (filename) which adds readability. The 3 arg form can be done with either lexical or bareword filehandles.

It's a vague reference, but I think this is the section of the tutorial that Kevin is referring to.

Quote

There is also a 3-argument version of open, which lets you put the special redirection characters into their own argument:

open( INFO, ">", $datafile ) || die "Can't create $datafile: $!";

In this case, the filename to open is the actual string in $datafile , so you don't have to worry about $datafile containing characters that might influence the open mode, or whitespace at the beginning of the filename that would be absorbed in the 2-argument version. Also, any reduction of unnecessary string interpolation is a good thing.

Yes, thats exactly what I was referring too. If you ever have to write code that is used in a high risk environment the three argument style is pretty much mandatory. -------------------------------------------------

Filehandles are normally global in scope, but lexical filehandles are not, unless you declare them globally. Also "strict" will catch a typo in a filehandle name if you use a lexical filehandle but it can't for a bareword filehandle, and perl automatically closes a file when a lexical filehandle goes out of scope. You can also use the case of your choice with a lexical filehandle where as with a bareword you should stick with all uppercase to avoid collisions with reserved words. -------------------------------------------------