in reply to Re: File::Binary:howto goto a position in file
in thread File::Binary:howto goto a position in file

Thanks for the explanation. But I still get the same error, here is a small test script (called fio.pl):
#! /usr/bin/perl use strict ; use File::Binary ; use Fcntl 'SEEK_SET'; my $fb = File::Binary->new("fio.pl"); $fb->seek(10, SEEK_SET ) ; $fb->close ;


Luca

Replies are listed 'Best First'.
Re^3: File::Binary:howto goto a position in file
by dragonchild (Archbishop) on Mar 12, 2006 at 13:50 UTC
    That's because File::Binary's code is wrong. Specifically, the seek() method is written as so:
    sub seek { my $self = shift; my $seek = shift; unless ($self->{_is_seekable}) { carp "FH is not seekable" if $DEBUG; return 0; } $self->{_fh}->seek($seek) if defined $seek; $self->_init_bits(); return $self->{_fh}->tell(); }

    Which is wrong. The whole module is written rather sloppily, frankly. Which is not surprising, given that the test suite doesn't even have a test for seek().

    Furthermore, the test coverage for the 2874 tests is only

    ---------------------------- ------ ------ ------ ------ ------ ------ + ------ File stmt bran cond sub pod time + total ---------------------------- ------ ------ ------ ------ ------ ------ + ------ blib/lib/File/Binary.pm 79.2 47.6 37.5 87.1 95.0 100.0 + 73.1 Total 79.2 47.6 37.5 87.1 95.0 100.0 + 73.1 ---------------------------- ------ ------ ------ ------ ------ ------ + ------
    If I were you, I would find some other way to do what you're trying to do.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      Ok, I thought it was a cool module, like guess_endian.
      Well, for what I need to do right now is only to be able to jump to an other position. Any suggestions what my best alternatives are?

      Thanks for your help!

      Luca