#!/usr/bin/perl use strict; use warnings; my $foo; # Replace with $_ accordingly my %data; my %table = ( 94 => "A8A40" ); my @fields = qw(Year Month Day Request_Seq Request_Type Record_Seq Record_Data); @data{ @fields } = unpack "A2A2A2A4A2A2A1486" , $foo; my ($Destination, $DestinationType) = unpack $table{$data{Record_Type}} , $data{Record_Data};