#!/usr/bin/perl use strict; use warnings; # First, open the file and read the contents... assuming one line open my $file, 'encrypted_file_name' or die "ERROR:\t$!\n"; my $enc_pass = shift( @{ [ <$file> ] } ); close $file; # Next, pipe the contents to gpg open my $gpg_command, "/usr/bin/gpg --option newfile oldfile | " my $gpg_out; while ( <$gpg_command> ) { $gpg_out .= $_; } close $gpg_command; print "$gpg_out\n"; exit;