in reply to Length-limiting handle

How about setting local $/ to a reference to integer before the call, and then read one scalar from the handle?

{ local $/ = \get_next_length(); $foo = <FH>; }

Are you decoding RIFF files, by chance? You may want to think about unpack's 'C4 V/A*' format ( I think that's correct for RIFF)

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: Length-limiting handle
by John M. Dlugosz (Monsignor) on Feb 20, 2003 at 05:30 UTC
    Yea, I cound have the "outer" function read the whole thing it's responsible for, then wrap a handle around that scalar to pass to the "inner" code to break that up, etc. until I'm down to primitive types. But, (1) a design goal is not to have size limits and the top level could be very large, and (2) it might be a pipe or other asynchronous source and I can start processing before I can read it all.