comparison interps/clc-intercal/CLC-INTERCAL-Base-1.-94.-2/INTERCAL/Interface.pm @ 996:859f9b4339e6

<Gregor> tar xf egobot.tar.xz
author HackBot
date Sun, 09 Dec 2012 19:30:08 +0000
parents
children
comparison
equal deleted inserted replaced
995:6883f5911eb7 996:859f9b4339e6
1 package Language::INTERCAL::Interface;
2
3 # User interface for sick and intercalc
4
5 # This file is part of CLC-INTERCAL
6
7 # Copyright (c) 2006-2008 Claudio Calvelli, all rights reserved.
8
9 # CLC-INTERCAL is copyrighted software. However, permission to use, modify,
10 # and distribute it is granted provided that the conditions set out in the
11 # licence agreement are met. See files README and COPYING in the distribution.
12
13 use strict;
14 use vars qw($VERSION $PERVERSION);
15 ($VERSION) = ($PERVERSION = "CLC-INTERCAL/Base INTERCAL/Interface.pm 1.-94.-2") =~ /\s(\S+)$/;
16
17 use Carp;
18 use Language::INTERCAL::Exporter '1.-94.-2';
19
20 sub new {
21 @_ >= 3 or croak "Usage: Language::INTERCAL::Interface->new"
22 . "(SERVER, PREFER, TRY_LIST)";
23 my $class = shift;
24 my $server = shift;
25 my $prefer = shift;
26 my $lasterr = "Could not load user interface";
27 for my $name ($prefer || @_) {
28 my $modname = "Language::INTERCAL::Interface::$name";
29 eval "require $modname";
30 if ($@) {
31 $lasterr = $@;
32 next;
33 }
34 my $obj = eval { $modname->new($server) };
35 return $obj if $obj && ref $obj;
36 $lasterr = $@ if $@;
37 };
38 $lasterr .= "\n" if $lasterr !~ /\n$/;
39 die $lasterr;
40 }
41
42 1;
43