# Print the airport name to a given airport code # /iata prints the name for the airport code (iata or other) # use strict; #use English; use DBI; use Irssi 20021028; use vars qw($VERSION %IRSSI); $VERSION = "1.1"; %IRSSI = ( authors => "Alexander Kuehn", contact => "iata\@nagilum.org", name => "iata", description => "Lookup airport codes in different DBs", license => "GPLv3", changed => "Sat Aug 11 2007" ); my ($sth_iata,$sth_icao,$sth_wac,$sth_tn); my $iata_db=".irssi/iata.db"; sub cmd_iata { my $iata = uc shift; if ($iata eq "") { Irssi::print("USAGE: /IATA "); } else { my $found=0; $sth_iata->execute($iata); my $name=($sth_iata->fetchrow_array())[0]; if ($name) { Irssi::print("wikipedia.org says: IATA $iata is $name"); $found=1; } $sth_icao->execute($iata); $name=($sth_icao->fetchrow_array())[0]; if ($name) { Irssi::print("wikipedia.org says: ICAO $iata is $name"); $found=1; } $sth_wac->execute($iata); $name=($sth_wac->fetchrow_array())[0]; if ($name) { Irssi::print("world-airport-codes.com says: $iata is $name"); $found=1; } $sth_tn->execute($iata); $name=($sth_tn->fetchrow_array())[0]; if ($name) { Irssi::print("travelnotes.org says: $iata is $name"); $found=1; } if (!$found) { Irssi::print("Unknown iata code: $iata"); } } } Irssi::command_bind('iata', \&cmd_iata); my $dbh = DBI->connect("dbi:SQLite:$iata_db","",""); $sth_iata = $dbh->prepare("SELECT airport FROM iata WHERE iata=? LIMIT 1;"); $sth_icao = $dbh->prepare("SELECT airport FROM iata WHERE icao=? LIMIT 1;"); $sth_wac = $dbh->prepare(qq{SELECT name || ", " || country || " (." || abbrev || ",+" || tel || ")" from wac WHERE code=? LIMIT 1;}); $sth_tn = $dbh->prepare("SELECT airport FROM tn WHERE code=? LIMIT 1;");