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?

tshepang
  • 12,111
  • 21
  • 91
  • 136
chaos
  • 122,029
  • 33
  • 303
  • 309
  • 3
    "open my $fh, '>', $filename or die $!" is even more preferred. – Eugene Yarmash Feb 05 '10 at 21:21
  • 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`. – chaos Feb 05 '10 at 21:25
  • 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... – Michael Carman Feb 05 '10 at 23:13
  • I posted it because I was having a hard time finding it. I answered it because I found it. – chaos Feb 05 '10 at 23:30
  • 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. – chaos Feb 05 '10 at 23:32
  • @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. – chaos Feb 05 '10 at 23:35
  • 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*. – Michael Carman Feb 06 '10 at 00:25
  • 1
    In that vein, I've found `corelist` (http://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. – j_random_hacker Feb 07 '10 at 17:55

2 Answers2

11

Looks like 5.6.0.

chaos
  • 122,029
  • 33
  • 303
  • 309
  • 3
    In other words, Late Jurassic :) – DVK Feb 05 '10 at 21:26
  • 4
    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. – chaos Feb 05 '10 at 21:28
  • Aah, I was curious if `open my $fh, '>:raw', $filename` came about at the same time -- it appears so. – ephemient Feb 05 '10 at 21:36
  • ephemient: ':raw' is an io layer, they were added in 5.8.0. – Alexandr Ciornii Feb 05 '10 at 22:04
  • @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? – ephemient Feb 05 '10 at 22:14
  • 3
    Although you found the answer, how you found the answer is probably the interesting part. So, what did you do? :) – brian d foy Feb 06 '10 at 04:25
  • Since the perl deltas aren't in a subdirectory or anything, the trick winds up being googling `site:perldoc.perl.org +"History / Changes" `. – chaos Feb 06 '10 at 19:05
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.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
  • And for the record, Perl 5.6 was released on March 22, 2000 (http://search.cpan.org/dist/perl/pod/perlhist.pod) – nobody May 15 '14 at 19:26