ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/dm-support.ext
Revision: 1.2
Committed: Wed Jul 19 08:52:57 2006 UTC (17 years, 10 months ago) by root
Branch: MAIN
Changes since 1.1: +21 -16 lines
Log Message:
make use of ->reply, implement say in perl, still untested but activated perl-eval

File Contents

# Content
1 #! perl
2
3 # untested dm support extension
4
5 use Storable qw/nfreeze thaw/;
6
7 my %global; # for use by eval'ed commands
8
9 cf::register_extcmd perl_eval => sub {
10 my ($pl, $data) = @_;
11
12 my ($token, $data) = split / /, $data, 2;
13
14 unless ($pl->flag (cf::FLAG_WIZ)) {
15 $pl->send ("ext $token error permission denied");
16 return;
17 }
18
19 my ($code, $arg) = split /\0/, $data, 2;
20
21 $arg = eval { thaw $arg };
22 my @res = eval $code;
23
24 $@ ? $pl->send ("ext $token error " . nfreeze $@)
25 : $pl->send ("ext $token ok " . nfreeze \@res);
26 };