aspangler has asked for the wisdom of the Perl Monks concerning the following question:

I need something like
( $val ) = unpack( "N", $raw )
except that the number can be negative.

The code should be platform neutral.

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: How do I unpack a signed long in big endian?
by Anonymous Monk on Jun 21, 2002 at 03:50 UTC
    $val = unpack( "N", $raw ^ "\x80\0\0\0" ) - ( 1 << 31 );