Commits

Xu Xiaodong committed 2ea3817

add config file support

Comments (0)

Files changed (3)

 # author:    Xu Xiaodong <xxdlhy@gmail.com>
 # license:   GPL
 # created:   2011 Feb  7
-# modified:  2011 Apr 13
+# modified:  2011 Apr 27
 #
 
 use Modern::Perl;
+use Config::Tiny;
 use LWP::UserAgent;
 use HTTP::Cookies;
 
-my $username = '';
-my $password = '';
+my $conf = Config::Tiny->read("$ENV{HOME}/.gaccountrc");
+
+my $username = $conf->{gad}->{user};
+my $password = $conf->{gad}->{pass};
 
 my $ua = LWP::UserAgent->new( cookie_jar => HTTP::Cookies->new() );
 
 # author:    Xu Xiaodong <xxdlhy@gmail.com>
 # license:   GPL
 # created:   2011 Feb  7
-# modified:  2011 Apr 13
+# modified:  2011 Apr 27
 #
 
 use strict;
 use warnings;
 
+use Config::Tiny;
 use Mail::IMAPClient;
 
+my $conf = Config::Tiny->read("$ENV{HOME}/.gaccountrc");
+
 # Account information
-my $user = '';
-my $pass = '';
+my $user = $conf->{gmail}->{user};
+my $pass = $conf->{gmail}->{pass};
 
 # Gmail unread count
 my $imap = Mail::IMAPClient->new(
 # author:    Xu Xiaodong <xxdlhy@gmail.com>
 # license:   GPL
 # created:   2011 Feb  7
-# modified:  2011 Apr 13
+# modified:  2011 Apr 27
 #
 
 use strict;
 use warnings;
 
+use Config::Tiny;
 use WebService::Google::Reader;
 
-my $user = '';
-my $pass = '';
+my $conf = Config::Tiny->read("$ENV{HOME}/.gaccountrc");
+
+my $user = $conf->{gmail}->{user};
+my $pass = $conf->{gmail}->{pass};
 
 my $gr = WebService::Google::Reader->new(
     username => $user,