in reply to How to organize file records

If the problem here is that you need to know how to read a specific number of bytes for some pre-defined record size, you can use Perl's built-in read() function:
my $REC_SIZE = 16; # 16 byte records. my $buf; # location to store records my @records; # array of records. while (read FH, $buf, $REC_SIZE) { push @records, $buf; }
You may also need to use binmode() depending on your operating system. And btw, you can use Perl's length() function to determine the size of scalars.

Replies are listed 'Best First'.
I know how to read files etc.
by Corion (Patriarch) on Mar 15, 2000 at 22:21 UTC
    Thanks for the information on how to actually read files - it seems like I didn't make my problem clear enough :) I already know all the basics (and some more) about file handling in Perl. But what I do not know is, how one in "general" handles reading stuff from files that are structured as records or even less structured (i.e. records of different length). Your proposal to hardcode the record size strikes me as a bad idea, since I have to recalculate the record size each time I find some new information about the file.

    As I watch this discussion unfold, it comes to me that maybe my first kludgy idea of parsing the string passed to unpack() wasn't that bad after all ...