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

[perl #112826] Tie::StdHandle read() offset argument

From:
Father Chrysostomos via RT
Date:
June 22, 2012 06:16
Subject:
[perl #112826] Tie::StdHandle read() offset argument
Message ID:
rt-3.6.HEAD-5009-1340371000-1119.112826-15-0@perl.org
On Tue May 08 15:46:57 2012, kryde wrote:
> With debian packaged perl 5.14.2 and Tie::StdHandle version 4.2, the
> "offset" argument to read() is not obeyed by a tied handle.  For
>    example
> foo.pl
> 
>     use strict;
>     use Tie::StdHandle;
>     {
>       open PP, '</dev/null';
>       my $buf = "xxxxxxxxxx\n";
>       read PP, $buf, 2, 5;
>       print "plain:     \"$buf\"\n";
>     }
>     {
>       tie *TT, 'Tie::StdHandle', '</dev/null';
>       my $buf = "xxxxxxxxxx\n";
>       read TT, $buf, 2, 5;
>       print "StdHandle: \"$buf\"\n";
>     }
>     exit 0;
> 
> prints
> 
>     plain:     "xxxxx"
>     StdHandle: ""
> 
> where I expected StdHandle to leave $buf as "xxxxx" the same as a
>    plain
> handle.
> 
> Perhaps the READ method should notice an offset argument and pass it
>    on
> to the real read().  I get some joy from the following.  Prototyping
> prevents passing @_ directly does it?, the same as done in OPEN().
> 
> sub READ {
>   (@_ > 3
>    ? read($_[0],$_[1],$_[2],$_[3])
>    : read($_[0],$_[1],$_[2]))
> }

Fixed in commit 7762c37, where I used a slightly different approach.

-- 

Father Chrysostomos


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



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