ag4ve has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to figure out what's happening, but for some reason I don't get any output after 'print $to_gpg':

use strict; use warnings; use utf8; use Data::Dumper; use GnuPG::Interface; STDOUT->autoflush(1); my $gpg_pass = $ENV{'GPG_PASSWORD'}; print Dumper(encrypt("hello world", "swilson")); sub encrypt { my ($text, $email) = @_; return "No data" if (not defined($text) or ref($text) ne 'ARRAY'); print "In encrypt email: [$email]\n"; my @recipients; push @recipients, $email; my $oGpg = GnuPG::Interface->new(); push (@{$oGpg->options->extra_args}, '--keyserver-options', 'no-auto +-key-retrieve' ); $oGpg->options->hash_init( meta_interactive => 0, always_trust => 1, armor => 1, homedir => './gnupg', recipients => [@recipients], ); my ($gpg_to, $gpg_from, $gpg_err, $gpg_stat, $gpg_log) = (IO::Handle->new(), IO::Handle->new(), IO::Handle->new(), IO::Handle->new(), IO::Handle->new()); my $handles = GnuPG::Handles->new( stdin => $gpg_to, stdout => $gpg_from, stderr => $gpg_err, status => $gpg_stat, logger => $gpg_log, ); foreach my $handle ($gpg_to, $gpg_from, $gpg_err, $gpg_stat, $gpg_lo +g) { $handle->autoflush(1); } $oGpg->passphrase($gpg_pass); my $pid = $oGpg->sign_and_encrypt(handles => $handles); print "In encrypt pid: [$pid]\n"; print $gpg_to @$text; print "In encrypt HERE0\n"; close $gpg_to; print "In encrypt HERE1\n"; my $raCiphertext; @$raCiphertext = <$gpg_from>; # reading the output my @aErrorOutput = <$gpg_err>; # reading the error my @aStatusInfo = <$gpg_stat>; # read the status info print "In encrypt HERE2\n"; # Cleanup foreach my $handle ($gpg_from, $gpg_err, $gpg_stat, $gpg_log) { $handle->close; } print "In encrypt HERE3\n"; waitpid $pid, 0; print "In encrypt raCiphertext: [" . @$raCiphertext . "]\n"; return "No data" if (ref($raCiphertext) ne 'ARRAY' or scalar(@$raCip +hertext) == 0); my $result = result_check($email, @aStatusInfo); return $result, $raCiphertext; }

Replies are listed 'Best First'.
Re: GnuPG::Interface preventing print
by poj (Abbot) on Jan 28, 2015 at 15:15 UTC
    return "No data" if (not defined($text) or ref($text) ne 'ARRAY');

    Try

    print Dumper(encrypt(["hello world"], "swilson")); # ^ ^ add
    poj