I am trying to encrypt files and then put them someplace else. But after using Crypt::OpenPGP to encrypt them, the files are just sitting in memory as a text and I can't seem to push them to a file. If I put in print $ciphertext they appear in the log.txt file as the encrypted text. I need them in their own separate file to be moved around and so on.
Does anyone have any ideas?
See Code:
sub process_dir{ my $directory = shift; my @file = &open_directory($directory); for my $processing(@file){ my $file= &encrypt_file($processing); my $encrypted_output = "$dir/$processing"; #$dir is a global d +eclared at the top open OUT, "> $encrypted_output" || die "can't $!"; select OUT; print $file; rename("$dir/$file", "$dir/$file.pgp"); } } sub encrypt_file{ my $file = shift; my $pgp = Crypt::OpenPGP->new; my $ciphertext = $pgp-encrypt( Filename => $file, Recipient => $key_id, Armour => 1, ); return($ciphertext);

In reply to How do I get the output of Crypt::OpenPGP to a file by chinesebob

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.