You might want to take a look at Crypt::OpenPGP. It's
a pure Perl implementation of the OpenPGP standard and is
compatible with PGP2, PGP5, GnuPG, etc.
Sample usage:
use Crypt::OpenPGP;
my $pgp = Crypt::OpenPGP->new( PubRing => $pubring);
my $ciphertext = $pgp->encrypt(
Data => $data,
Recipients => $key_id,
Armour => 1,
);