Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm having some trouble with tying a filehandle on Perl 5.6.1 (Debian Woody). The minimal testcase I've got is like this:
#!/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"; }
When I run it, I get:
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.


In reply to TIEHANDLE problem by sgifford

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-25 10:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found