So the key information you need is that you need to use the bit operators to manipulate the bits in each byte to extract the interesting bit fields. In particular use & (bitwise and) and a bit mask to isolate bit fields, and use the bitwise shift operators >> and << to move fields of bits about. For example, to isolate the op code you'd do something like:
use strict;
use warnings;
my $byte = 0b00100100;
my $opCode = ($byte & 0b11100000) >> 5;
printf "Opcode is 0x%02X\n", $opCode;
Prints:
Opcode is 0x01
See perlop for details about the various Perl operators.
True laziness is hard work