hi

thanks for all your help in the past

how do i go about creating an array of hashes

eg. suppose i want to get information about email messages, and each
message has a subject, date, from etc. i want to store the following in a
hash.

But there are more than one messages, therefore, i have to create an array
of hashes. eg hash holds information about each email message.





please take a look at the following code....I am probably doing something
wrong.
thankyou

your help is always appreciated.


Jeremy A.




sub messageInfo ($) {
                my @messageStatList = @_[0];

                foreach (@messageStatList) {
                                my %messageInfo;                        # 
creating my hash                                                      
                                $pop3C->send("TOP $_{Number} 1\n");
                                while (($response = <$pop3C>) && ($response !~ 
/^\./)) {
                                        if ($response =~ /From:\s([^\n]*)/) {
                                                        $response =~ 
/From:\s([^\n]*)/;
                                                        $messageInfo{From} = $1;
                                #                       print "$1\n";
                                        }
                                        if ($response =~ /Subject:\s([^\n]*)/) {
                                                        $response =~ 
/Subject:\s([^\n]*)/;
                                                        $messageInfo{Subject} = 
$1;
                                #                       print "$1\n";
                                        }
                                        $messageInfo->{Size} = $_->{Size}; #c
                                        $messageInfo->{Number} = $_->{Number};
                                        if ($response =~ /Date:\s([^\n]*)/) {
                                                        $response =~ 
/Date:\s([^\n]*)/;
                                                        $messageInfo{Date} = $1;
                                #                       print "$1\n";
                                        }
                                }
                                push(@messageInfoList,%messageInfo);     # 
pushing hash into the array.
                }
                                                foreach (@messageInfoList) {
                                                
                                                        print "$_{From}\n"; 
                                                        print "$_{Subject}\n";
                                                        print "$_{Size}\n";
                                                        print "$_{Date}\n";
                                                        print "$_{Number}\n";
                }
        return @messageInfoList;
}









Reply via email to