in reply to Unpacking byte stream long/quad little/big endian fields

I faced a similar problem while writting Net::SFTP::Foreign.

My solution was to create a set of functions which pop the data from the buffer, allowing me to write code as the following:

my $buffer = read ...; my $len = get_int32($buffer); my $cmd = get_int8($buffer); my $txt = get_string($buffer);
This is the module implementing those functions: Net::SFTP::Foreign::Buffer.