develooper Front page | perl.perl5.porters | Postings from March 2011

Re: serious PerlIO trouble :(

Thread Previous | Thread Next
From:
David Leadbeater
Date:
March 12, 2011 01:38
Subject:
Re: serious PerlIO trouble :(
Message ID:
07769F4E-661B-4EC0-A6CE-F1B47A90B95B@dgl.cx
On 12 Mar 2011, at 09:23, H.Merijn Brand wrote:
[...]
> $ perl perlio.pl 1
> UTF-16:Unrecognised BOM 7061 at /pro/lib/perl5/5.12.2/i686-linux-64int-ld/IO/Handle.pm line 1.
> Compilation failed in require at perlio.pl line 17.
> Exit 255

Presumably because the open pragma isn't applying inside IO::Handle

If I add a 3rd case, which rather evilly just takes the code from IO::Handle, but therefore means it is within the pragma's scope:

    if ($t == 2) {
       { no warnings 'once';
           *IO::Handle::getline = sub {
               my $this = shift;
               return scalar <$this>;
           };
       }

       while (my $r = *ARGV->getline) {
           print $r;
       }
       exit 0;
    }

Then it works.
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