Re: Count messages in a Imap-Mailfolder

[email protected] ("John W. Krahn")
Newsgroups perl.beginners
Message-ID <[email protected]>
Michelle Konzack wrote:
> Hello John,

Hello,

> thank you for your answer.

You're welcome.

> Am 2008-06-02 17:34:30, schrieb John W. Krahn:
>> According to the documentation for that module:
>>
>>     list
>>           my $message_size  = $imap->list($message_number);
>>           my $mailbox_sizes = $imap->list;
>>
>>         This method returns size information for a message, as indicated
>>         in the single optional parameter, or all messages in a mailbox.
>>         When querying a single message a scalar value is returned. When
>>         listing the entire mailbox a hash is returned. On failure,
>>         "undef" is returned.
>>
>>
>> So if you use list() with no message number supplied it will return a 
>> *reference* to a hash that contains the message numbers as the keys and 
>> the corresponding message sizes as the values.
> 
> Since I am begining to learn Perl, how do I get the Value from the hash?

# Get a hash reference from $imap->list
my $mailbox_sizes = $imap->list;

my $total_size;

# Get the total size from the dereferenced hash values
$total_size += $_ for values %$mailbox_sizes;


> Note:  I have no internet @home which mean, I have only the perldoc
>        documentation and not more and I have not found the thing
>        about hashes.

perldoc perl
[snip]
        Tutorials

            perlreftut          Perl references short introduction
            perldsc             Perl data structures intro
            perllol             Perl data structures: arrays of arrays
[snip]

        Reference Manual

[snip]
            perldata            Perl data structures
[snip]
            perlref             Perl references, the rest of the story


> Thanks, Greetings and nice Day

And you have a nice day as well.



John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.