#!/usr/bin/perl -- use strict; use warnings; use Data::Dump; my $rawAsHex = q'0001000000004f914f1c0b01004253434130300000000500004341303030303000000001434130303031340000000243413030303232000000034341303030323400000004434130303032390000000100224e43656c6c3000000002004253434130310000000500054341303130303100000006434130313030340000000743413031303130000000084341303130313500000009434130313031360000000100224e43656c6c30000000030042534341303200000006000a'; my $raw = pack 'H*', $rawAsHex; my @stack = unpack q{ A2 ### Header Record Id : 1 Byte A2 ### File Format Version : 1 Byte A16 ### Timestamp : 8 Bytes A2 ### No. of BSCs : 1 Byte ### For each BSC ... A2 ### BSC Id : 1 Byte A2 ### Application Version : 1 Byte A4 ### BSC Name : 2 Bytes A4 ### Number of Cells : 2 Bytes ### For each Cell ... A4 ### Cell Pointer : 2 Bytes A18 ### Cell Name : 9 Bytes A4 ### Number of Neighbour Cells : 2 Bytes ### For each Neighbour Cell to this BSC ... A4 ### Cell Pointer : 2 Bytes A18 ### Cell Name : 9 Bytes }, $rawAsHex; my $id = unpack 'C*', pack 'H*', $stack[0]; my $version = unpack 'C*', pack 'H*', $stack[1]; my $time = unpack 'H*', pack 'H*', $stack[2]; ## WHAT?! dd [ $id, $version, $time , \@stack ]; __END__ [ 0, 1, "000000004f914f1c", [ "00", "01", "000000004f914f1c", "0b", "01", "00", 4253, 4341, 3030, "000000050000434130", 3030, 3030, "000000014341303030", ], ]