#!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" . . . $/; 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" . . . $/; close STDIN; close INFILE; open STDIN, "<&OLDIN" or warn "cannot reset STDIN = <&OLDIN using 2-argument open(): $!"; close OLDIN; print "Input Text to ensure we switched back to original STDIN: "; my $in = ; print "READ FROM STDIN:$/$in$/"; exit; #### 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; ------------------------------------------------------------