-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreflect-server.pl
54 lines (48 loc) · 1.21 KB
/
reflect-server.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use XLLoop;
{
package MyFuncs;
use Data::Dump;
use List::Util qw/sum/;
use namespace::clean;
# MyFuncs.somefunc(1) will send arguments as [1]
# MyFuncs.somefunc(1,2) will send arguments as [1,2]
# IF you send a range of cells
# MyFuncs.somefunc(B1) will send arguments as [B1]
# MyFuncs.somefunc(B1:B3) will send arguments as [[B1,B2,B3]]
# MyFuncs.somefunc(B1:D1) will send arguments as [[[B1,C1,D1]]]
# MyFuncs.somefunc(B1:D3) will send arguments as [[[B1,C1,D1], [B2,C2,D2], [B3,C3,D3]]]
sub sum_two {
my ($a, $b) = @{+shift};
return $a + $b;
}
sub sum_all {
return sum(@{+shift});
}
sub array {
return [0..10];
}
sub matrix {
return [[1,2.1],['hello',4]];
}
sub dump {
say "dumping:";
dd @_;
}
}
{
package TestFunc;
use namespace::clean;
sub div_two {
my ($a, $b) = @{+shift};
return $a / $b;
}
}
my $h = ReflectionHandler->new;
$h->addMethods('MyFuncs.', 'MyFuncs'); # addMethods(prefix, package)
$h->addMethods('TestFunc.', 'TestFunc');
my $f = XLLoopServer->new( handler => $h );
$f->start;