#!perl
use strict;
use warnings;
use Socket;
use MIME::Base64; # in core, thanks choroba
my $blob = "BAABAAXwAACGAAAAAAABLAAAAAAAAAAArBQEKA==";
$blob = decode_base64($blob);
my (
$dataLength, # 2 bytes
$type, # 2 bytes
$version, # 1 byte
$rank, # 1 byte
$flags, # 2 bytes
$serial, # 4 bytes
$ttl, # 4 bytes
$reserved, # 4 bytes
$timestamp, # 4 bytes
$data ) = unpack( 'S S C C S L N L L a*', $blob );
# http://www.perlmonks.org/?node_id=1152688 see Tux comment
print $dataLength, "\n";
print "$type\n";
print "$version\n";
print "$rank\n";
print "$flags\n";
print "$serial\n";
print "$ttl\n";
print "$reserved\n";
print "$timestamp\n";
print inet_ntoa($data) . "\n";
|