In terms of getting this fixed, you might want to work step by step through the converted commands.
The 'sudo' command, unless your sudoers permissions are set up just so, will prompt you for a password when run. If the perl script is being run via cron in an account without the ability to sudo in passwordless fashion, the conversion will fail everytime.
You might want to test by trying something like:
#!/usr/bin/perl
system 'sudo echo "Hello World!"';
And if you're running as root, you can skip the 'sudo' bit altogether.
The 'pgp' command may or may not work the way you think it should depending on the setting of the HOME enviroment variable. And so it goes.