I'm tearing my hair out over this and I can't seem to find any answers.
I'm working on an app that is going to be reading from a file that will be made up of PGP encrypted e-mails. I'm going to read these in to an array so that I can process them one at a time.
My problem is that I can't figure out how to get MIME::Decoder to decode anything when I feed it a scalar - even if it's wrapped in a filehandle via IO::Wrap. It all works fine if I'm reading and writing to files, but I don't want to have to write every message to a file, decode it, write it back to a different file, then open and read it again to decode it.
When I run this through the debugger, $decoded is 1 - which according to the docs means it decoded something, but I'm at a loss how to make this work with just scalars.
I'm sure I've got a syntactial error in how I'm trying to do it, but I can't find any examples of what I'm trying to.
use strict; use Crypt::OpenPGP; use Data::Dumper; use MIME::Tools; use MIME::Decoder; use IO::Wrap; $|++; &decode; sub decode { my $decoder = new MIME::Decoder "quoted-printable"; my ($text, $outtext); { local $/; open(my $fh, '<', 'orders.txt') or die "Problem:$!"; $text = <$fh>; } $text = wraphandle($text); $outtext = wraphandle($outtext); my $decoded = $decoder->decode( $text, $outtext);
Any help would be appreciated!
In reply to Using scalar instead of file handle in MIME::Decoder by Popcorn Dave
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |