How to decode cbor encoded hex string using perl libraries?

I have a cbor encoded hex string.

when decoding using CBOR::XS

But I am getting an error as garbage after CBOR object, at offset 2 (octet 0x41) at line 6.

use CBOR::XS;
# Replace this with your CBOR-encoded hex data
my $hex_data = "";

# Decode CBOR data
my $decoded_data = CBOR::XS::decode_cbor($hex_data);
# Manually format the decoded data
use Data::Dumper;

print Dumper($decoded_data);


  • The sub does not want the hex representation of the bytes but the bytes themselves.

    my $data = pack "H*", $hex_data;