sgifford has asked for the wisdom of the Perl Monks concerning the following question:
When I run it, I get:#!/usr/bin/perl + use warnings; use strict; use Symbol; use IO::Handle; + our $f1; $f1 = gensym; open($f1,"<&STDIN") or die "dup of STDIN failed\n"; tie *$f1, 'TieTest'; print "Read: ",scalar(<$f1>); + package TieTest; sub TIEHANDLE { my $class = shift; my $obj = { }; bless $obj, $class; warn "TIEHANDLE: $obj\n"; $obj; } + sub READLINE { warn "READLINE\n"; return "line\n"; }
TIEHANDLE: TieTest=HASH(0x80fcacc) Use of uninitialized value in <HANDLE> at tietest.pl line 14. readline() on unopened filehandle at tietest.pl line 14. Use of uninitialized value in print at tietest.pl line 14. Read:
It seemed to work for some other monks in the chatterbox, so it might be a version-specific problem.
Anybody have any ideas for making this work? All I'm really looking for is a way to make my filehandle objects work with regular perl file operations, like seek and angle-brackets.
The actual code emulates seek on a remote file via FTP, using the FTP REST and ABOR commands. If I open a ZIP file and pass it to Archive::Zip, it's able to read the table-of-contents of a multi-GB ZIP file and extract individual files without downloading the whole thing. I'm trying to get everything polished up for CPAN, and this is about the last thing on my list.
Thanks!
Update: Two more data points: First, everything besides READLINE works: read, getc, seek, tell, eof, etc. Second, everything works just fine on a perl 5.8.3 system I had handy.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: TIEHANDLE problem
by bart (Canon) on Apr 02, 2006 at 10:31 UTC | |
by davido (Cardinal) on Apr 04, 2006 at 06:55 UTC | |
Re: TIEHANDLE problem
by idsfa (Vicar) on Apr 02, 2006 at 08:04 UTC | |
by sgifford (Prior) on Apr 02, 2006 at 13:02 UTC | |
Re: TIEHANDLE problem
by nothingmuch (Priest) on Apr 02, 2006 at 08:54 UTC |