Open p5pRT opened 16 years ago
On Tue Feb 12 08:49:02 2008\, KES wrote:
This is a bug report for perl from Eugen.Konkov@aldec.com\, generated with the help of perlbug 1.35 running under perl v5.8.8.
open my $ff\, ">&"\, STDOUT or die "1: $!"; open FH\, ">&"\, $ff or die "2: $!"; open F2\, ">&"\, FH or die "3: $!"; print F2 'hello';
This code outputs 'hello' to STDOUT; but on WWW: http://perldoc.perl.org/functions/open.html was wrote that I can use $ff
# open for input\, reusing the fileno of $fd open(FILEHANDLE\, "\<&=$fd") or open(FILEHANDLE\, "\<&="\, $fd) I have tried to change my code to next:
open my $ff\, ">&"\, STDOUT or die "1: $!"; open FH\, ">&$ff" or die "2: $!"; open F2\, ">&"\, FH or die "3: $!"; print F2 'hello';
and it DIED with message "2: Invalid argument at ..."
This appears to be a documentation bug...
open my $ff\, ">&"\, STDOUT or die "1: $!"; open FH\, ">&$ff" or die "2: $!";
does not work\, but:
open my $ff\, ">&"\, STDOUT or die "1: $!"; my $fd = fileno($ff); open FH\, ">&$fd" or die "2: $!";
and so does:
open FH\, ">&"\, $ff or die "2: $!";
2. Furthermore help does not explain situations when redirecting one "in momory" file to an other my $mem1; open F1\, ">"\, \$mem1; my $mem2; open F2\, ">"\, \$mem2; print $mem1 'AAA'; print $mem2 'BBB';
open F1\, ">&"\, F2; print F1 'aaa'; print F2 'bbb';
print $mem1; print $mem2; exit 0;
Expected results: AAABBBaaabbb Actual results: AAABBBbbb
I'm assuming you made an error copying the code since the code supplied won't work. (print $mem1 'AAA';)
#!/usr/bin/perl
my $mem1; open F1\, ">"\, \$mem1; my $mem2; open F2\, ">"\, \$mem2; print F1 'AAA'; print F2 'BBB';
open F1\, ">&"\, F2; print F1 'aaa'; print F2 'bbb';
print "$mem1\n"; print "$mem2\n";
__END__
Output: AAA BBBbbb
Chaning it to open F1\, ">&="\, F2;
#!/usr/bin/perl
my $mem1; open F1\, ">"\, \$mem1; my $mem2; open F2\, ">"\, \$mem2; print F1 'AAA'; print F2 'BBB';
open F1\, ">&="\, F2; print F1 'aaa'; print F2 'bbb';
print "$mem1\n"; print "$mem2\n";
__END__
Output: AAA BBBaaa
The RT System itself - Status changed from 'new' to 'open'
Migrated from rt.perl.org#50756 (status was 'open')
Searchable as RT50756$