#hypothetical module use Binary::Parser; $compiled_template = Binary::Parser->new( template => 'nCC C/a'); my @result = $compiled_template->unpack($binary_data); # would be nice to have, like regex ? (0 or one) at the end # it will match C C/a # C C/a B8 # C C/a B8 f ... $optional_template = Binary::Parser->new( template => 'C C/a (B8 ff cc)?');