Yeah, the docs aren't that vague for Net::IMAP::Simple in my opinion. It says that $imap->list($number) returns the number of bytes. It'll also return all the sizes as an array @a = $imap->list if you call it without an argument.

Normally I wouldn't write out the whole thing (as I think it spoils most of the fun), but in this case I actually wanted it for my own purposes and it's really just a cut and paste from the docs anyway. (spoilers within)

use strict; use Net::IMAP::Simple; use Number::Format; my $fmt = new Number::Format; # Create the object my $imap = Net::IMAP::Simple->new('yourisp') || die "Unable to connect to IMAP: $Net::IMAP::Simple::errstr\n"; # Log on if(!$imap->login('loluser', 'secretpassword')){ print STDERR "Login failed: " . $imap->errstr . "\n"; exit(64); } # Print the subject's of all the messages in the INBOX my $nm = $imap->select('INBOX'); my $total = 0; for my $i ( 1 .. $nm ) { my $size = $imap->list($i); print "", ($imap->seen($i) ? "* " : " "), $fmt->format_bytes($siz +e, 1), " bytes\n"; $total += $size; } $imap->quit; print "\n total = ", $fmt->format_bytes($total, 1), " bytes\n";

-Paul


In reply to Re: IMAP & File Sizes by jettero
in thread IMAP & File Sizes by pileofrogs

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.