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;