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

2

6

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?

Scurlock answered 5/2, 2010 at 21:15 Comment(8)
"open my $fh, '>', $filename or die $!" is even more preferred.Alinaaline
That isn't really just the open operation, though, that's the open operation plus a form of failure handling that may or may not be appropriate to context. I only wanted to talk about open.Scurlock
Is there any particular reason you posted this question & answer? There are lots of changes documented in perldelta and no reason for SO to duplicate those one at a time...Rimose
I posted it because I was having a hard time finding it. I answered it because I found it.Scurlock
Also, consider me to have said something rude and aggressive here, because that's what I really feel like doing in response to the tone of your comment.Scurlock
@eugene y: I started to edit my question to reflect the my $fh syntax, then realized (as related research had turned up) that that syntax actually became valid at the same time as the three-argument open. So mucking with that would just confuse the issue.Scurlock
I see your something rude and aggressive and raise you an arrogant and abusive reply. Seriously, I assumed you knew about perldelta and was curious what made this question special. Being unable to find a particular needle in one of a dozen haystacks is a perfectly valid answer. It can be a challenge to find the when for a particular what.Rimose
In that vein, I've found corelist (search.cpan.org/dist/Module-CoreList) invaluable for telling me what version of Perl contains a given module. E.g. corelist /File::Spec/ from the command line. Very handy when you're trying to figure out which additional modules you need to install on some other computer.Appearance
P
6

When you have those sorts of questions, start crawling back through the perl*delta documents. You can mostly skip the minor versions since those versions shouldn't introduce major features.

In this case, you'd find it in perl56delta.

Proximal answered 6/2, 2010 at 0:22 Comment(1)
And for the record, Perl 5.6 was released on March 22, 2000 (search.cpan.org/dist/perl/pod/perlhist.pod)Ellingston
S
11

Looks like 5.6.0.

Scurlock answered 5/2, 2010 at 21:19 Comment(7)
In other words, Late Jurassic :)Brahmi
Some of my early professional sysadmin tasks were done in Perl 4, when it was new and exciting. You kids get your "fire" and your "wheel" off my grass.Scurlock
Aah, I was curious if open my $fh, '>:raw', $filename came about at the same time -- it appears so.Dymoke
ephemient: ':raw' is an io layer, they were added in 5.8.0.Amalgamate
@Alexandr Ciornii: perl56delta says that :raw and :crlf are new in 5.6.0, though. Perhaps not in the same form as in 5.8.0?Dymoke
Although you found the answer, how you found the answer is probably the interesting part. So, what did you do? :)Proximal
Since the perl deltas aren't in a subdirectory or anything, the trick winds up being googling site:perldoc.perl.org +"History / Changes" <what you're looking for>.Scurlock
P
6

When you have those sorts of questions, start crawling back through the perl*delta documents. You can mostly skip the minor versions since those versions shouldn't introduce major features.

In this case, you'd find it in perl56delta.

Proximal answered 6/2, 2010 at 0:22 Comment(1)
And for the record, Perl 5.6 was released on March 22, 2000 (search.cpan.org/dist/perl/pod/perlhist.pod)Ellingston

© 2022 - 2024 — McMap. All rights reserved.