#!/usr/bin/perl -w use strict; my %fields; my @field_names = qw/FIELD1 FIELD2 FIELD3 FIELD4 FIELD5 FIELD6/; # $pack_definition derived from the format in the Packet Layout Guide, e.g. # ignore T18 # FF15 1B 8 A028 3043 D2070000 my $pack_definition = 'a4 a2 a1 a4 a4 a8'; while ( ) { @fields{@field_names} = unpack($pack_definition,$_); } #this is just to display what we got, in hex while (my($k,$v) = each %fields) { print sprintf("% 9s",$k) . ' => ' . hex($v) . $/; } __DATA__ FF151B8A0283043D2070000