RE: Processing binary data

2016-03-31 Thread Duncan Ferguson
Lars, I believe 'unpack' is the right way to go, you just need to get the template right ('N' in your example) See the explanation on http://www.perlmonks.org/?node_id=224666, especially the section on 'unpack' "unpack takes a template string and a scalar and returns a list of values." ($

Processing binary data

2016-03-31 Thread Lars Noodén
What are the best practices for working with binary data? If I read a span of binary data, say, into $packet like with read() below my ( $packet_size, $packet ); read( $client_socket, $packet_size, 4 ); $packet_size = unpack( "N", $packet_size ); read( $client_soc