El Módulo WWW::GMail

pp2@nereida:~/src/perl/MAIL$ gmail.pl
you have 0 new messages in your inbox
you have 31 contacts
3 of them are gmail addresses

pp2@nereida:~/src/perl/MAIL$ cat -n gmail.pl
 1  #!/usr/local/bin/perl -w
 2  use strict;
 3  use WWW::GMail;
 4
 5  my $obj = WWW::GMail->new(
 6      username => "USERNAME",
 7      password => "PASSWORD",
 8      cookies => {
 9              autosave => 1,
10              file => "./gmail.cookie",
11      },
12  );
13
14  my $ret = $obj->login();
15  if ($ret == -1) {
16      print "password incorrect\n";
17  } elsif ($ret == 0) {
18      print "unable to login $obj->{error}\n";
19      exit;
20  }
21
22  my @list = $obj->get_message_list('inbox');
23
24  # count the new messages in the inbox
25  my $new_msgs = 0;
26  for my $i ( 0 .. $#list ) {
27      $new_msgs += $list[$i]->[1]; # count the unread flags
28  }
29
30  print "you have $new_msgs new messages in your inbox\n";
31
32  my @contacts = $obj->get_contact_list();
33  print "you have ".(@contacts)." contacts\n";
34
35  my $gmail = 0;
36  for my $i ( 0 .. $#contacts ) {
37      $gmail += ($contacts[$i]->[3] =~ m/gmail\.com$/i);
38  }
39
40  print "$gmail of them are gmail addresses\n";
41
42  $obj->logout();

Casiano Rodríguez León
2012-02-29