my $mpw_file = IO::File->new( "<$mpw" ) || die "\n\nUnable to open master.passwd file. $!\n"; my $gnupg = GnuPG::Interface->new(); $gnupg->options->hash_init( armor => 1, homedir => '/root/.gnupg' ); $gnupg->options->push_recipients( 'foo@example.com' ); $gnupg->options->meta_interactive( 0 ); my @original_plaintext = <$mpw_file>; ##my $passphrase = "Three Little Pigs"; # We'll let the standard error of GnuPG pass through # to our own standard error, by not creating # a stderr-part of the $handles object. my ( $input, $output, $error, $status_fh ) = ( IO::Handle->new(), IO::Handle->new(), IO::Handle->new(), IO::Handle->new() ); my $handles = GnuPG::Handles->new( stdin => $input, stdout => $output, stderr => $error, status => $status_fh ); # this sets up the communication # Note that the recipients were specified earlier # in the 'options' data member of the $gnupg object. my $pid = $gnupg->encrypt( handles => $handles ); # this passes in the plaintext print $input @original_plaintext; # this closes the communication channel, # indicating we are done close $input; close $mpw_file; my @ciphertext = <$output>; # reading the output my @status_info = <$status_fh>; # reading the status info my @error_output = <$error>; # reading the error print @ciphertext; print @status_info; print @error_output; waitpid $pid, 0; # clean up the finished GnuPG process # }}}