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:
my $key = 1;
my $cipher = Crypt::CBC->new( -key => $key );
my $ciphertext = $cipher->encrypt_hex('test');
print "$ciphertext \n";
Perhaps there is a strange interaction between the 2 modules. Can you use something else to generate the key?