I was unable to install
Crypt::Random, so I can't even attempt to replicate your error.
However, if I run a modified version of your code with only Crypt::CBC, it runs for me without errors:
use warnings;
use strict;
use Crypt::CBC;
my $key = 1;
my $cipher = Crypt::CBC->new( -key => $key );
my $ciphertext = $cipher->encrypt_hex('test');
print "$ciphertext \n";
__END__
53616c7465645f5f5847db7edbe4cfb66a7ce84481016e42
Perhaps there is a strange interaction between the 2 modules. Can you use something else to generate the key?