Created
August 15, 2012 10:12
-
-
Save kazu634/3358428 to your computer and use it in GitHub Desktop.
remember the milkから取得したXMLファイルのpretty print
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# for formality's sake | |
use strict; | |
use warnings; | |
use utf8; | |
# for XML parse | |
use XML::Simple; | |
use Data::Dumper; | |
use Encode 'encode'; | |
# ================= | |
# === Main Part === | |
# ================= | |
my $xml = XML::Simple->new; | |
my $data = $xml->XMLin("index.xml"); | |
my %hash; | |
foreach my $key ( keys %{ $data->{"entry"} } ) { | |
my $title = $data->{"entry"}->{$key}->{"title"}->{"content"}; | |
my $updated = $data->{"entry"}->{$key}->{"updated"}; | |
my $due = | |
$data->{"entry"}->{$key}->{"content"}->{div}->{div}->[0]->{span}->[1] | |
->{content}; | |
$key =~ s/tag:rememberthemilk.com,1999:(.+)$/$1/; | |
$title = encode( "UTF-8", $title ); | |
$updated = encode( "UTF-8", $updated ); | |
$due = encode( "UTF-8", $due ); | |
$hash{$key} = { | |
"title" => $title, | |
"updated" => $updated, | |
"due" => $due, | |
}; | |
} | |
# print Dumper %hash; | |
for my $key ( sort keys %hash ) { | |
my $title = $hash{$key}->{"title"}; | |
my $updated = $hash{$key}->{"updated"}; | |
my $due = $hash{$key}->{"due"}; | |
print "$key\t$title\t$due\t$updated\n" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment