#!/usr/bin/perl -w use strict; use Jcode; use LWP::Simple; use Data::Dumper; use HTTP::MobileAgent; require XML::Simple; my $URL = 'http://www.nttdocomo.co.jp/p_s/imode/spec/ryouiki.html'; do_task(@ARGV); sub do_task { my $html = Jcode->new(get($URL))->tr('0-9', '0-9')->euc; $html =~ s/\n+/\n/g; my $re = regexp(); my %map; while ($html =~ /$re/igs) { my($model, $width, $height, $color, $depth) = ($1, $2, $3, $4, $5); $map{uc($model)} = { width => $width, height => $height, color => $color eq 'カラー', depth => $depth, }; } output_code(\%map); } sub output_code { my($map) = @_; my $xml = XML::Simple->new; printf <<'TEMPLATE', $xml->XMLout($map); %s TEMPLATE ; } sub regexp { return <<'RE'; ([A-Z]+\d+\w*).*? .*?(?:)? .*?(?:)? (.*?)×(.*?) .*? (白黒|カラー)(?:.*?)(\d+)(?:色|階調) RE ; }