- Perl ›
- builtin functions ›
- here
unpack function - restore packed data
You can use the unpack function to restore the data packed in binary format with pack function.
my @values = unpack($format, $packed);
The first argument is the format.
The second argument is the packed data.
As for the return value, the restored data is returned as an array.
Restore data packed in signed 32 - bit binary format
If the three integers are packed in a signed 32-bit binary format, use the unpack function to restore them as follows:
my $packed = pack("l3", 7, 8, 9); my @values = unpack("l3", $packed);
@values will be array called (7, 8, 9).
Restore floating point packed data in signed double binary format
If the three floating point numbers are packed in a double precision floating point double binary format, restore them as follows:
my $packed = pack("d3", 0.5, 1.2, 5.4); my @values = unpack("d3", $packed);
Endian conversion
Endian conversion is explained in pack function.
A list of formats that can be used with the unpack function.
For a list of formats that can be used with the unpack function, refer to the format list of pack function.
More details
For more information about the pack function, see the official documentation Introduction to pack and unpack and unpack function.