# backup.pl (version of 2006.12.28) # reading sitemaps.xml open(INPUT, "sitemaps.xml") || die "can't open your 'sitemaps.xml'"; local $/ = ""; while () { if (/http:\/\/.+\/blog-entry-([0-9]+)\.html<\/loc>/) { $num = $1; if (/([^\+]+).+<\/lastmod>/) { $index{$1} = $num; } } } close (INPUT); $/ = "\n--------\n"; $count = 1; while (<>) { if (!defined($author) && /^AUTHOR: (.+)$/m) { $author = $1; } # "03/31/2005 06:16:23" -> "2005-03-31T06:16:23" if (/^DATE: ([0-9][0-9])\/([0-9][0-9])\/([0-9][0-9][0-9][0-9]) ([0-9][0-9]:[0-9][0-9]:[0-9][0-9])/m) { $date = "$3-$1-$2T$4"; } if (/^STATUS: ([a-zA-Z]+)/m && uc $1 eq "DRAFT") { # 1st "STATUS" line == "Draft" # Draft entry } else { $n = $index{$date}; if ($n == 0 || $n < $count) { die "something wrong ! (date:'$date')"; } while ($count < $n) { # output dummy entry print <