#!/usr/bin/perl -w use strict; use LWP::Simple; my (@switches, @woorden); while (@ARGV) { $_ = shift; if (/^--$/) { push @woorden, @ARGV; } elsif (/^-/) { push @switches, $_; } else { push @woorden, $_; } } my $all = grep /^(?:-\w*a|--all)$/, @switches; if (grep /^(?:-\w*h|--help)$/, @switches) { print qq{ Usage: $0 [options] word ... options: -a --all List all matches -h --help Display usage information \n}; exit 0; } for my $woord (@woorden) { $woord =~ s/(\W)/sprintf '%%%02x', ord $1/ge; my $page = get "http://www.vandale.nl/opzoeken/woordenboek/?zoekwoord=$woord"; while ($page =~ s{(.*?).*?((?:
.*?
)+)}{}si) { my ($woord, $betekenis) = ($1, $2); for ($woord, $betekenis) { s[][\n]gi; s/<.*?>//g; s/´/'/g; s/&#(\d+);/chr $1/ge; } $betekenis =~ s/^/ /gm; print "$woord\n$betekenis\n"; last if not $all; } }