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


I'm trying to reconstruct a dBase Memo file. The file is broken into 512-byte chunks, each representing a Memo.

How can I read these 512-byte chunks? Should I be hacking at the record separator?
---
donfreenut
  • Comment on How do I slurp an arbitrary number of bytes from a file?

Replies are listed 'Best First'.
Re: How do I slurp an arbitrary number of bytes from a file?
by davorg (Chancellor) on Mar 22, 2001 at 20:59 UTC

    You can use read as merlyn points out, but you can also do it by setting the input record separator to a scalar reference.

    { local $/ = \512; while (<FILE>) { # process the 512 bytes you have in $_ } }
    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me

Re: How do I slurp an arbitrary number of bytes from a file?
by merlyn (Sage) on Mar 22, 2001 at 20:55 UTC