Dear Perl Monks, I seek your wisdom (and patience)

I've included my current work below. It's a basic attempt to get mail and parse the MIME attachments. I can get the email without problems using the Mail::POP3Client. I am attempting to send the header and body of each message to the MIME Parser and save the resulting parsed text and files. When I run the script, a number of folders are created in the output directory, but with zero contents.

In other examples I've seen using MIME::Parser there seems to be an object (forgive me if it's called by another name) called $parser->parts, but I can't find it defined in the MIME::Tools (or MIME::Parser) documentation. My first probably is probably not knowing what "\*STDIN" represents. I know STDIN, but I don't want to be manually piping something to the script; I want to work with strings I already have in the script.

Your wisdom is much appriciated.

#!/usr/bin/perl -w ## import modules use lib '/Users/squiddy/sandbox/lib/'; use Mail::POP3Client; use MIME::Parser; ## create a new MIME parser object my $parser = new MIME::Parser; $parser->output_under("/Users/squiddy/sandbox/mailtemp/"); $parser->output_to_core(1); ###### code removed for simplicity ######### ## get mail $pop = new Mail::POP3Client( USER => "squiddy", PASSWORD => "notmypw", HOST => "pop3.squiddy.com", USESSL => true ); ###### code removed for simplicity ######### ## loop through each item on the POP3 server for ($i = 1; $i <= $pop->Count(); $i++) { ## get the unique email UIDL (out of a returned string "N XXXXXXX" +) $mailnum = $pop->Uidl($i); @maildat = split(" ",$mailnum); $mailnum = $maildat[1]; # print "$mailnum\n"; ## if it doesn't already exist in the database if (exists $hash{$mailnum}) { # print "nothing here\n"; } else { ###### code removed for simplicity ######### ## get email body $emailmessage = $pop->HeadAndBody($i); ###### code removed for simplicity ######### ## output the MIME parts $entity = $parser->parse($emailmessage) or die "parse failed\n +"; } } ## close the connection $pop->close(); ###### code removed for simplicity #########

In reply to MIME::Parser tries but fails to save files by Squiddy

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.