in reply to IMAP & File Sizes

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