#!/usr/bin/perl use strict; use warnings; use Crypt::GPG; use Data::Dumper; my $gpg = new Crypt::GPG; $gpg->gpgbin('/usr/bin/gpg'); $gpg->secretkey('xxxxxxxxxx'); $gpg->passphrase('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); my $inputfile = shift; my $outputfile = shift; open my $ciphertext_fh, '<', $inputfile or die "couldn't open $inputfile: $!"; open my $output_fh, '>', $outputfile or die "couldn't open $outputfile for writing: $!"; my @ciphertext = <$ciphertext_fh>; my (@plaintext) = $gpg->decrypt(\@ciphertext) or die "didn't work: $!"; print $output_fh @plaintext; close $ciphertext_fh; close $output_fh;