Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

perl 5.010 Can't locate object method "seek" via package "IO::Handle"

by jandrew (Chaplain)
on May 05, 2016 at 20:08 UTC ( [id://1162300]=perlquestion: print w/replies, xml ) Need Help??

jandrew has asked for the wisdom of the Perl Monks concerning the following question:

I confess that I never attempted to seek on an IO::Handle when I was writing for perl 5.10, but I am currently attempting to release a package that includes this action and I would like to verify support back to 5.10. I get the title error in my travis-ci tests (with the container based Debian). Any thoughts on how to get around this? I suspect some incremental support occurred from 5.012 onward and that there is a known way around it for perls 5.010 and earlier but I'm unable to find it with a search. I would appreciate any suggestions.

The top level docs aren't complete on the GitHub page yet

  • Comment on perl 5.010 Can't locate object method "seek" via package "IO::Handle"

Replies are listed 'Best First'.
Re: perl 5.010 Can't locate object method "seek" via package "IO::Handle"
by stevieb (Canon) on May 05, 2016 at 20:42 UTC

    Put use FileHandle; at the top of the module that is producing the errors. Some older perls don't load it automatically.

    Example:

    $ perl -E 'open $fh, "<a.txt"; $fh->seek(0, 0);' Can't locate object method "seek" via package "IO::Handle" at -e line +1.
    $ perl -MFileHandle -E 'open $fh, "<a.txt"; $fh->seek(0, 0);'

    Or, depending on the code in question (you don't specify where it is), you could use the seek function instead (no need for FileHandle):

    seek $fh, 0, 0;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1162300]
Approved by dorko
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-18 05:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found