in reply to Re: getc skips ahead
in thread getc skips ahead

Boris, That did it! It's hard to believe that the problem hasn't occurred before on tens of thousands of images, but ...

Also, the binmode documentation does not mention getc as one of the functions it affects, so who knew?

Anyway, many thanks for saving my bacon! Stephen

Replies are listed 'Best First'.
Re^3: getc skips ahead
by PodMaster (Abbot) on Aug 15, 2004 at 14:14 UTC
    Also, the binmode documentation does not mention getc as one of the functions it affects, so who knew?
    I don't really think it needs to, it already says
    In other words: regardless of platform, use binmode() on binary data, like for example images.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re^3: getc skips ahead
by hv (Prior) on Aug 15, 2004 at 19:43 UTC

    Note that the piece of information that gives it away is this: "in the problem file, [getc] returns 270, 782, 4367, 4368". You'd normally expect getc() to be reading one byte at a time, and therefore always returning numbers in the range 0..255; only if the file is being read in a different mode can larger integers be returned.

    Update: misread the details.

    Hugo

      The original post sure sounds like he's doing getc, tell (for debugging), and something else in a loop, and the "270,782,..." are the results of the tell. The question is what is in that "something else" that advances the file pointer, and how getc's different return after binmode makes it work right.

        Oops, I misread that entirely, and ignored the fact that the "before" list of numbers were also greater than 255 to boot.

        Hugo