pryrt has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks, when I released Games::Literati 0.032, I discovered the hard way (thanks, CPAN Testers) that in-memory files are not compatible with Perl 5.6. The module itself doesn't use in-memory files, but part of my test suite did. So I reworked the test suite to not use in-memory files. I then found Perl::MinimumVersion 1.38, and ran perlver on my module and test files, and all claimed to be Perl 5.6.0 compatible. However, when I released Games::Literati 0.040, I was surprised to see CPAN Testers flag me for failure when tested under Perl 5.6.2. :-(

tl;dr summary

  1. What Perl version introduced open() using '<&'? I know that by 5.8.5, it works, and apparently it doesn't in 5.6.2.
  2. Should I consider it a bug in Perl::MinimumVersion 1.38 that perlver claimed my test suite was compatible with 5.6.0?
  3. Should I just skip the portions of my test suite that require the '<&'? Or should I try to find an alternate?
  4. Easy way to get 5.6.0 on Windows? (Alternately, pre-made virtual machine with 5.6.0?)

tl;dr details

CPAN Testers error message: Unknown open() mode '<&' at t/03_input_processing.t line 46.

Specifically, line 46 refers to:

open STDIN, '<&', $fh or do { warn "set STDIN = \$fh=\\$fh: $!"; return undef; };

(I find it strange that it flagged on line 46, because line 42 has similar code

open my $oldin, "<&STDIN" or do { warn "dup STDIN to \$fh=\\$fh: $!"; return undef; };
...which seems to be using the same feature. So why did it flag on 46, but not 42?)

(full source: https://metacpan.org/source/PETERCJ/Games-Literati-0.04/t/03_input_processing.t)

perlver output:

C:>perlver t\03_input_processing.t ------------------------------------------------------ | file | explicit | syntax | external | | ------------------------------------------------------ | | t\03_input_processing.t | 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 | ------------------------------------------------------

Before I send a bug report to Perl::MinimumVersion for not catching that apparent incompatibility with 5.6.2, I did some more searching, and found open() with more than two arguments. Reading that, it seems to indicate that 5.6.1 was the first to include 3-argument open(). Did I read that correctly? If so, am I correct in concluding that's a separate bug in perlver()? ie, that it should have flagged 3-argument open as requiring 5.6.1?

I couldn't find the perldelta that indicated when '<&' open mode was introduced. I tried looking specifically for an archive of the Perl 5.6 perldocs, but my google-foo isn't that good, apparently. And I don't have access to Perl 5.6.* to look at the docs directly. (I'm mostly on Windows, and Strawberry Perl doesn't go back that far, and ActivePerl only allows older versions for Business or Enterprise Editions. I have access to a machine at $work that has 5.8.5, which is how I know it works by then. But while doing a quick run of a perl script during my coffee break is forgivable, installing a whole old version of perl on that server, even if I did a local installation, would be highly frowned upon, and I enjoy my $paycheck.) So is there a Monk who knows or can easily point me to when '<&' was introduced? I'd like to have 'proof' to supply during my '<&' bug report, but cannot find it, aside from my anecdotal evidence from the CPAN Testers 5.6.2 failure.

Also, more importantly, how do I solve this problem in my test suite? For now, the redirection is only used because the function it's testing gets its input from STDIN, and for the test suite, I wanted to provide input to that function to test it :-). But the redirection isn't used in the module itself, so it's 5.6-compatible. Should I figure out a workaround for the test suite? If so, I desire recommendations from my fellow Monks as to a 5.6-compatible method of testing that function. Or should I just plan skip_all => "Cannot redirect STDIN in perl $]" if $] lt '5.008';?

(Historical note: I'm reluctant to claim that the module requires something higher than 5.6, when it's just the test suite that requires it. That seems rude, especially since the original module that I inherited apparently worked under 5.6, and nothing I've done to improve the module should change that. Why be rude to a Scrabble/Literati player from the early 2000s who doesn't feel the need to upgrade perl just to optimize points, who wants bug fixes and/or to include Words with Friends scoring now?)

Finally, is there any easy way to get a copy of 5.6.0 for Windows? Or is there a small, easy to install linux virtual machine that has 5.6.0 pre-installed?

UPDATE: fix typos

UPDATE: add <readmore>

Replies are listed 'Best First'.
Re: open('<&'), Perl::MinimumVersion, and my test suite
by pryrt (Abbot) on Apr 05, 2016 at 22:19 UTC

    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).

    tl;dr summary

    1. What Perl version introduced open() using '<&'? I know that by 5.8.5, it works, and apparently it doesn't in 5.6.2.
      5.6.0 for 2-argument, 5.8.0 for 3-argument
    2. Should I consider it a bug in Perl::MinimumVersion 1.38 that perlver claimed my test suite was compatible with 5.6.0?
      I am now convinced it's a bug in Perl::MinimumVersion
    3. Should I just skip the portions of my test suite that require the '<&'? Or should I try to find an alternate?
      I will attempt to switch to 2-argument open() for my dups
    4. Is there an easy way to get 5.6.0 on Windows? (Alternately, pre-made virtual machine with 5.6.0?)
      Still open

    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.)

Re: open('<&'), Perl::MinimumVersion, and my test suite
by RonW (Parson) on Apr 06, 2016 at 17:38 UTC

    After reading about Perl::MinimumVersion, I agree that it's a bug in that module. Go ahead and make a bug report.

    As for your tests, not unreasonable to skip the tests that won't run on 5.6, but ultimately you need to decide if it's worth the effort to work out an alternate testing method.