#!/usr/bin/perl -w # # The asterisk-getnumber is Copyright (c) 2008 Tomas Edwardsson. Iceland. All right reserved. # # You may distribute under the terms of either the GNU General Public License or the Artistic License, # as specified in the Perl README file. # This program fetches data from http://ja.is/ and updates the name of the caller if it is found. use strict; use CGI; use LWP::Simple; my $q = new CGI; $SIG{ALRM} = sub { print "Content-Type: text/plain\n\nÓþekkt\n"; exit(0); }; alarm 2; my $name = 'Óskráð í símaskrá'; if ($q->param('cid')) { if (length($q->param('cid')) == 7) { my $content = get("http://ja.is/simaskra?q=" . $q->param('cid')); $content =~ s/^.*class="name .*?\>//s; $content =~ s/<.*$//s; $name = $content if ($content); } else { $name = 'Óþekkt'; } } alarm 0; print "Content-Type: text/plain\n\n$name\n";