Hacking Gmail

(Grace) #1

Chapter 7 — Gmail Libraries 135


quotaInfo = ga.getQuotaInfo()
quotaMbUsed = quotaInfo[QU_SPACEUSED]
quotaMbTotal = quotaInfo[QU_QUOTA]
quotaPercent = quotaInfo[QU_PERCENT]
print “%s of %s used. (%s)\n” % (quotaMbUsed, quotaMbTotal,
quotaPercent)


Setting Yourselves Up for the Remaining Chapters


To aid you in your coding over the next few chapters, you shall also need a small


Perl module of your own, which tidies up the boring things such as logging in.
Listing 7-4 gives the script Utils.pm, which you should place within the directory


in which you wish to work. You will need to place your own username and pass-
word in the place indicated.


Listing 7-4:Utils.pm

package Utils;


require Mail::Webmail::Gmail;


require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(login strip_bold);


sub login {
return Mail::Webmail::Gmail->new(
username => “USERNAME”,
password => “PASSWORD”
);
}


get rid of and in subjects


sub strip_bold {
my $str = shift;
$str =~ s/(.*)<\/b>/$1/;
return $str;
}


1;

Free download pdf