#!/usr/bin/perl -w ###################################################################### # Copyright (C) 2004 Martijn van Oosterhout # # # # This program is free software; you can redistribute it and/or # # modify it under the terms of the GNU General Public License # # as published by the Free Software Foundation; either version # # 2 of the License, or (at your option) any later version. # # # ###################################################################### use strict; my %hash; my $station; my %affiliations = ( 'Australian Broadcasting Corporation' => 4, 'Cable/Satellite' => undef, 'Community TV' => undef, 'Imparja' => 6, 'Nine Network' => 1, 'Prime TV' => 3, 'SBS Network' => 5, 'Seven Network' => 3, 'Southern Cross Network' => 8, 'Ten Network' => 2, 'WIN Television' => 1, ); while(<>) { next if /^#/; chomp; if( /^$/ ) { if( defined $station ) { $hash{affiliation} = $affiliations{$hash{affiliation}}; print "insert into a (code,country,city,serverid,name,state,afid) values ('$station',"; print join(",", map { (not defined $_)?"null":"'$_'" } @hash{qw(country city serverid name state affiliation)}); print ");\n"; undef $station; } } elsif( /^\[(.*)\]/ ) { $station = $1; %hash = (); } elsif( /^(\w+)=(.*)/ ) { $hash{$1} = $2; } else { die "Unrecognised line [$_]\n"; } }