[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] read() and sysread()



Doing this with read():

        open(IN, "somefile.txt");
        $offset = 1024; #for instance
        read(IN, $doc, 100, $offset);
        print $doc;

prints lines of binary characters (?) followed by the _first_ 100
characters of the file. I expected 100 characters from '$offset' into the
file. Am I expecting the wrong thing or is MacPerl misbehaving here?

Doing:

        read(IN, $doc, $offset);
        read(IN, $doc, 100);
        print $doc;

gets what I want, the first 100 characters after $offset, but seems a
roundabout method.

sysread() behaves (or misbehaves) similarly, but not identically.

Alan Fry