in reply to open('<&'), Perl::MinimumVersion, and my test suite
I realized that while I didn't want to build old versions of perl from source, I could probably peruse the source. So I found the 5.6.0, 5.6.2, and 5.8.0 tarballs at http://www.cpan.org/src/5.0/, and looked for perlfunc.pod in each.
The perlfunc POD for v5.6.0 does list the 3-argument open FILEHANDLE,MODE,LIST, so 3-argument alone isn't enough to make something 5.6-incompatible. Further, "You may use & after >, >>, <, +>, +>>, and +<", so '<&' obviously existed in 5.6.0. However, "Duping file handles is not yet supported for 3-argument open()", which answers that question.
The perlfunc POD for v5.6.2 says the same. It changes in v5.8.0, the wording changes to "If you use the 3 arg form then you can pass either a number, the name of a filehandle or the normal ''reference to a glob''."
Thus, 3-argument open() for duping of filehandles was introduced in v5.8.0. That's useful information for my Perl::MinimumVersion bug report.
As far as my other question: workarounds: the 5.6.0 POD implies that it will accept filehandle dup with 2-argument version. Thus I think that the following should be a good test case, which I will submit with my bug report, once I've figured out a machine/virtual machine where I can easily install perl 5.6.0 for testing (because I obviously cannot rely on perlver to let me know about 5.6.0 compatibility on these scripts).
#!c:\usr\bin\perl.exe use warnings; use strict; use 5.006; # this is a lie; really, require 5.8.0 for 3-argument open +() to dup STDIN open my $infile, '<',$0 or die "cannot open $0 for read as \$infile: $ +!"; open INFILE, '<', $0 or die "cannot open $0 for read as INFILE: $!" +; open OLDIN, "<&STDIN" or die "cannot dup STDIN to OLDIN: $!"; close STDIN; open STDIN, '<&', $infile or warn "cannot set STDIN = \$infile using + 3-argument open(): $!"; # 3-argument dup is not valid perl 5.6. +0-5.6.2 print "READ FROM STDIN=<&\$infile:\n" . <STDIN> . <STDIN> . $/; close STDIN; close $infile; open STDIN, '<&INFILE' or warn "cannot set STDIN = <&INFILE using + 2-argument open(): $!"; # 2-argument dup should be valid perl 5 +.6.0 print "READ FROM STDIN=<&\$infile:\n" . <STDIN> . <STDIN> . $/; close STDIN; close INFILE; open STDIN, "<&OLDIN" or warn "cannot reset STDIN = <&OLDIN usin +g 2-argument open(): $!"; close OLDIN; print "Input Text to ensure we switched back to original STDIN: "; my $in = <STDIN>; print "READ FROM STDIN:$/$in$/"; exit;
(While debugging that, I learned that I'll have to switch from open($fh, '<&STDIN') to open(FILEHANDLE, '<&STDIN') to be able to use the dup feature.)
And it's perlver output:
C:>perlver perlver_bug.pl --------------------------------------------- | file | explicit | syntax | external | | --------------------------------------------- | | perlver_bug.pl | v5.6.0 | v5.6.0 | n/a | | --------------------------------------------- | | Minimum explicit version : v5.6.0 | | Minimum syntax version : v5.6.0 | | Minimum version of perl : v5.6.0 | --------------------------------------------- C:>perlver --blame perlver_bug.pl ------------------------------------------------------------ File : perlver_bug.pl Line : 2 Char : 1 Rule : _perl_5006_pragmas Version : 5.006 ------------------------------------------------------------ use warnings; ------------------------------------------------------------
As to why it flagged on 46, but not 42: I'm now reasonably confident it's because 42 was a 2-argument open()/dup, whereas 46 was the invalid 3-argument open()/dup.
Anybody have a favorite linux VM (that's easy to run on a Windows host) that already has perl 5.6.0 installed? Or maybe one that's easy to perlbrew? (I've never used perlbrew, but seen it mentioned here.)
|
|---|