in reply to Re: Unpacking fixed length records
in thread Unpacking fixed length records

I goofed and called it "Fixed length records" when what would have made more sense was Run Length Encoded (RLE). Oh well. Yes, you are correct in that approach would work - I'm trying to understand how to make it work from an unpack format example. I did recently discover that it's not the format that's bad - something is odd about my data that's breaking the unpack() call. Not that it matters but I can't really do read() and sysread() since I've just grabbed the entire 10K string from a call to /usr/bin/uncompress. See 203336 and 203230 for more on that. I'll probably spend an hour tonight and follow a hexdump of the data to see where unpack is dying. As far as I know there's no way to debug unpack and see where it's falling down. It just either works or it doesn't (and it's damn annoying).

__SIG__ printf "You are here %08x\n", unpack "L!", unpack "P4", pack "L!", B:: +svref_2object(sub{})->OUTSIDE

Replies are listed 'Best First'.
Re^3: Unpacking fixed length records
by Aristotle (Chancellor) on Oct 09, 2002 at 20:07 UTC
    You could separate the parts of the unpack format, making sure to manually consume each part as you go along. It's more work than should be necessary of course - unpack should tell us where it failed, but alas, it doesn't. So you could repeatedly call something like
    my @list = eval { unpack "x$skip $format", $data }; { die "$@" || last }
    making sure that $skip contains the correct value between calls.

    Makeshifts last the longest.