Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When did the file mode in Perl's open become a separate argument?

Tags:

perl

changelog

Once upon a time, you opened files in Perl like so:

open(FH, ">$filename");

At some point, for many good reasons including some very sticky ones involving filenames with leading spaces, this syntax became available (and, immediately, preferred):

open(FH, '>', $filename);

What version of Perl did we get that syntax with?

like image 526
chaos Avatar asked Feb 05 '10 21:02

chaos


People also ask

How many arguments does open take?

Most often, open gets invoked with three arguments: the required FILEHANDLE (usually an empty scalar variable), followed by MODE (usually a literal describing the I/O mode the filehandle will use), and then the filename that the new filehandle will refer to.

How do I open a reading file in Perl?

If you want to open a file for reading and writing, you can put a plus sign before the > or < characters. open DATA, "+>file. txt" or die "Couldn't open file file.

How do I check if a file exists in Perl?

Perl has a set of useful file test operators that can be used to see whether a file exists or not. Among them is -e, which checks to see if a file exists.


1 Answers

Looks like 5.6.0.

like image 82
chaos Avatar answered Oct 19 '22 18:10

chaos