develooper Front page | perl.perl5.porters | Postings from May 2012

[perl #8149] problem with write() and a tie()d filehandle

Thread Previous | Thread Next
From:
Brian Fraser via RT
Date:
May 26, 2012 17:24
Subject:
[perl #8149] problem with write() and a tie()d filehandle
Message ID:
rt-3.6.HEAD-7788-1338078254-871.8149-15-0@perl.org
On Sat Dec 29 04:29:43 2001, abeltje wrote:
> write() on a tie()d filehandle complains about an unopened filehandle.
> 
> The printf() on the that same tie()d filehandle works ok.
> 
> I looked at the documentation but couldn't find any mention of write()
> not beeing
> supported.
> 
> This program demonstrates it (confirmed for ActivePerl 5.6.1 build
> 628).
> 
> #!perl
> use warnings FATAL => 'all';
> use strict;
> 
> {
>     package FakeOut;
>     sub TIEHANDLE { bless \( my $scalar ), shift; }
>     sub PRINT     { my $self = shift; $$self .= shift; }
>     sub PRINTF    {
>         my $self = shift;
>         my $fmt = shift;
>         $$self .= sprintf $fmt, @_;
>     }
> 
> }
> 
> my( $text, $numb );
> format FAKEOUT =
> @<<<<<<<<<< @>>>>>
> $text,      $numb
> ..
> 
> my $fake = tie *FAKEOUT, 'FakeOut';
> foreach $text ( qw( one two three four five ) ) {
>     $numb = length $text;
> #    printf FAKEOUT "%-10s %5s\n", $text, $numb;
>     write FAKEOUT;
> }
> 
> print $$fake;
> 
> __END__
> 
> write() on unopened filehandle FAKEOUT at tiedwrite.pl line 27.
> 

Is this a bug? Wouldn't you have to define a WRITE method for the tied
handle for this to work?

--hugmeir


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=8149

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About