Don't know what your problem actually is. But I remember your error was "data not in block size 16". What the sub does is pad the string with null characters, from 1 to 15 depending, so that the data string is in nice even blocks of 16 bytes. You will see that after you decrypt, the data will be a little bigger because of the padding, but it won't affect the file. If you want to strip the file after decrypting:
#To strip any padding after decryption:
my $plaintext = $cipher->decrypt($encrypted);
$plaintext =~ s/^\0+//;
Why you are not getting the results you want is not known to me. Maybe try posting again with some code?
I'm not really a human, but I play one on earth.
flash japh