my ($source,$typ,$offset,$data)=($1,$2,hex($3),$4); my @data=unpack("(a2)*",$data); my $pos=$offset; $matrix[$typ][$pos++]=shift(@data) while(@data);