in reply to while behaviour on binary files

Just for fun, I considered what the unpack template for the record stream might be.
my ($inf, @dat) = unpack 'a4 (L (S/(xx) XX.@2/a XX.x4/a xx))<*', do +{ local $/; <DATFILE> }; while (@dat) { my ($ID, $s1, $s2) = splice(@dat, 0, 3); }
Not that it's sensible, practical or robust...

Replies are listed 'Best First'.
Re^2: while behaviour on binary files
by boftx (Deacon) on Nov 15, 2013 at 01:58 UTC

    Definite upvote on the preceding comment! unpack is your best friend when dealing with (presumed) fixed-width data records.

    It helps to remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.