#!/usr/bin/perl use LWP::Simple; use HTML::Entities; use feature qw/switch/; use strict; use warnings; # its channel, time1, prog1, time2, prog2 use constant { CHANNEL => 1, TIME1 => 2, PROG1 => 3, TIME2 => 4, PROG2 => 5, }; my $state = CHANNEL; my @html = split /\n/, get "http://www.tvgids.nl/nustraks/allezenders/"; while (my $line = shift @html) { given ($state) { when ($state == CHANNEL) { if ($line =~ /class="channel">(.*?)(.*?)/) { # next line has title $line = shift @html; $line =~ /title="Programmadetail: (.*?)">(.*?)<\/a>/; my $utf8 = decode_entities($1); utf8::encode($utf8); printf "%-20.20s\t", $utf8; $state = TIME2; } } when ($state == TIME2) { if ($line =~ /class="time">(.*?)/) { # next line has title $line = shift @html; $line =~ /title="Programmadetail: (.*?)">(.*?)<\/a>/; my $utf8 = decode_entities($1); utf8::encode($utf8); printf "%-20.20s\n", $utf8; $state = CHANNEL; } } } }