#!/usr/bin/env perl use strict; use warnings; use feature 'say'; use Crypt::GPG; my $gpg = Crypt::GPG->new; $gpg->gpgbin ('/usr/bin/gpg'); $gpg->secretkey ($ENV{SECRET_KEY}); $gpg->passphrase ($ENV{GPG_PP}); $gpg->armor (1); my $plaintext = 'PerlMonks Rocks!'; say "Plain text: $plaintext"; my @enctext = $gpg->encrypt ([$plaintext], $ENV{TO_EMAIL}); say "Encrypted text: @enctext"; my $decrypted = $gpg->verify (\@enctext); say "Decrypted text: $decrypted";