use strict; use warnings; use Data::Dumper; $Data::Dumper::Useqq = 1; # Here is the header value given my $hex = "0001000000004f914f1c0b01004253434130300000000500004341303030303000000001434130303031340000000243413030303232000000034341303030323400000004434130303032390000000100224e43656c6c3000000002004253434130310000000500054341303130303100000006434130313030340000000743413031303130000000084341303130313500000009434130313031360000000100224e43656c6c30000000030042534341303200000006000a"; # It appears to be incomplete, specifying 11 BSC blocks but only # containing two, and an initial fragment of a third. So, pad it. $hex .= "00" x 200; # As the given data is hex, pack it to get a byte string my $header = pack('H*', $hex); # And lets have a look at that byte string print Dumper($header); # # The specification for the header is: # # Header Record Id : 1 Byte # File Format Version : 1 Byte # Timestamp : 8 Bytes # No. of BSCs : 1 Byte # For each BSC ... # BSC Id : 1 Byte # Application Version : 1 Byte # BSC Name : 2 Bytes # Number of Cells : 2 Bytes # For each Cell ... # Cell Pointer : 2 Bytes # Cell Name : 9 Bytes # Number of Neighbour Cells : 2 Bytes # For each Neighbour Cell to this BSC ... # Cell Pointer : 2 Bytes # Cell Name : 9 Bytes # # # But, this doesn't stay in sync with the patterns evident # in the given data. In particular, each cell appears to # be represented in 11 bytes, and the neighbour cells # appear to follow the cells, rather than being nested # within the cells. # # It looks more like # # Header Record Id : 1 Byte # File Format Version : 1 Byte # Timestamp : 8 Bytes # No. of BSCs : 1 Byte # For each BSC ... # BSC Id : 1 Byte # Application Version : 1 Byte # BSC Name : 9 Bytes # Number of Cells : 2 Bytes # For each Cell ... # Cell Pointer : 2 Bytes # Cell Name : 9 Bytes # Unknown Byte # Number of Neighbour Cells : 2 Bytes # For each Neighbour Cell to this BSC ... # Cell Pointer : 2 Bytes # Cell Name : 9 Bytes # # This can be scanned as follows: # my @results = unpack ("C C H16 C X C/( C C a9 C X C/( n a9 ) C C X C/(n a9) )", $header); # And, we what we get out of it print "Results:\n" . Dumper(\@results) . "\n";