Skip to content

Instantly share code, notes, and snippets.

@moritz
Created March 26, 2011 21:27
Show Gist options
  • Save moritz/888651 to your computer and use it in GitHub Desktop.
Save moritz/888651 to your computer and use it in GitHub Desktop.
Cute Mojo::UserAgent example
use 5.012;
use Mojo::UserAgent;
use warnings;
binmode STDOUT, ':encoding(UTF-8)';
my $ua = Mojo::UserAgent->new();
my $r = $ua->get('http://www.loc.gov/standards/iso639-2/php/code_list.php');
for my $row ($r->res->dom('tr')->each) {
my ($three, $two, $english_name, $french_name) =
map $_->text, $row->find('td')->each;
say "$two $english_name" if length($two) == 2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment