diff Ikariam.pm @ 298:b3b845d30d4b

new cache mechanism
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sun, 07 Dec 2008 16:40:04 +0800
parents 1d0a55318262
children 58b36b18809f
line wrap: on
line diff
--- a/Ikariam.pm	Sun Dec 07 15:12:33 2008 +0800
+++ b/Ikariam.pm	Sun Dec 07 16:40:04 2008 +0800
@@ -113,6 +113,7 @@
 use HTTP::Cookies;
 use WWW::Mechanize;
 use XML::LibXML qw(:encoding);
+use YAML qw/LoadFile Dump DumpFile/;
 use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
 use POSIX;
 use utf8;
@@ -133,6 +134,7 @@
         debug => undef,
     };
 
+
     # if debug
     LWP::Debug::level('+trace');
 
@@ -1298,9 +1300,12 @@
     if($#cities<0) {
         die ("login failed\n");
     }
-    foreach(@cities) {
+    foreach (@cities) {
         $self->{'cities'}->{$_} = {};
         $self->{'cities'}->{$_}->{id} = $_;
+        if(-f "city-$_-dump.yaml") {
+            $self->{'cities'}->{$_} = LoadFile("city-$_-dump.yaml");
+        }
     }
 }