#!/usr/local/perl use strict; use warnings; use Web::Scraper; use URI; my $scraper = scraper { process 'table>tr>td[width="90"]', 'shigai[]' => 'TEXT'; }; my $uri = new URI( 'http://www.soumu.go.jp/joho_tsusin/top/tel_number/shigai_list.html'); my $res = $scraper->scrape($uri); my %shigai; foreach ( @{ $res->{shigai} } ) { $_ =~ s/\D+//g; next unless $_; $shigai{ $_ } = length($_); } foreach my $key (sort {$shigai{$b} <=> $shigai{$a}} keys %shigai) { printf "0%s\n", $key; }