line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Inline::WebChat; |
2
|
|
|
|
|
|
|
$VERSION = '0.62'; |
3
|
|
|
|
|
|
|
require Inline; |
4
|
|
|
|
|
|
|
@ISA = qw(Inline); |
5
|
1
|
|
|
1
|
|
12218
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
69
|
|
7
|
1
|
|
|
1
|
|
920
|
use WWW::Chat::Processor; |
|
1
|
|
|
|
|
10350
|
|
|
1
|
|
|
|
|
572
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Register as in an Inline Language Support Module (ILSM) |
11
|
|
|
|
|
|
|
sub register { |
12
|
|
|
|
|
|
|
return { |
13
|
0
|
|
|
0
|
0
|
0
|
language => 'WebChat', |
14
|
|
|
|
|
|
|
aliases => ['webchat'], |
15
|
|
|
|
|
|
|
type => 'interpreted', |
16
|
|
|
|
|
|
|
suffix => 'wc', |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# print out a warning |
21
|
|
|
|
|
|
|
sub usage_config { |
22
|
0
|
|
|
0
|
0
|
0
|
my $key = shift; |
23
|
0
|
|
|
|
|
0
|
"'$key' is not a valid config option for Inline::WebChat\n"; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# validate the config options |
28
|
|
|
|
|
|
|
sub validate { |
29
|
1
|
|
|
1
|
0
|
29
|
my $o = shift; |
30
|
1
|
|
|
|
|
8
|
while (@_) { |
31
|
0
|
|
|
|
|
0
|
my ($key, $value) = splice @_, 0, 2; |
32
|
0
|
|
|
|
|
0
|
croak usage_config($key); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# parse and process WebChat stuff |
37
|
|
|
|
|
|
|
sub build { |
38
|
0
|
|
|
0
|
0
|
0
|
my $o = shift; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# parse the code |
41
|
0
|
|
|
|
|
0
|
my $code = WWW::Chat::Processor::parse($o->{API}{code}); |
42
|
0
|
0
|
|
|
|
0
|
croak "Foo build failed:\n$@" if $@; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# find the path |
45
|
0
|
|
|
|
|
0
|
my $path = "$o->{API}{install_lib}/auto/$o->{API}{modpname}"; |
46
|
0
|
|
|
|
|
0
|
my $obj = $o->{API}{location}; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# check to see it's valid and if not, make a new path |
49
|
0
|
0
|
|
|
|
0
|
$o->mkpath($path) unless -d $path; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# and dump the code ... |
52
|
0
|
0
|
|
|
|
0
|
open FOO_OBJ, "> $obj" |
53
|
|
|
|
|
|
|
or croak "Can't open $obj for output\n$!"; |
54
|
0
|
|
|
|
|
0
|
print FOO_OBJ $code; |
55
|
0
|
|
|
|
|
0
|
close \*FOO_OBJ; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# now load it back up again |
60
|
|
|
|
|
|
|
sub load { |
61
|
1
|
|
|
1
|
0
|
4
|
my $o = shift; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# find out where it is |
64
|
1
|
|
|
|
|
8
|
my $obj = $o->{API}{location}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# read it in |
67
|
1
|
50
|
|
|
|
74
|
open FOO_OBJ, "< $obj" |
68
|
|
|
|
|
|
|
or croak "Can't open $obj for output\n$!"; |
69
|
1
|
|
|
|
|
41
|
my $code = join '', ; |
70
|
1
|
|
|
|
|
14
|
close \*FOO_OBJ; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# and run the code :) |
73
|
1
|
|
|
1
|
|
6
|
eval "package $o->{API}{pkg};\n$code"; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
37
|
|
|
1
|
|
|
1
|
|
1005
|
|
|
1
|
|
|
1
|
|
5464
|
|
|
1
|
|
|
|
|
27
|
|
|
1
|
|
|
|
|
979
|
|
|
1
|
|
|
|
|
42568
|
|
|
1
|
|
|
|
|
32
|
|
|
1
|
|
|
|
|
3846
|
|
|
1
|
|
|
|
|
69505
|
|
|
1
|
|
|
|
|
29
|
|
|
1
|
|
|
|
|
1327
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
73
|
|
74
|
1
|
50
|
|
|
|
530
|
croak "Unable to load WebChat module $obj:\n$@" if $@; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub info { |
78
|
0
|
|
|
0
|
1
|
|
my $o = shift; |
79
|
0
|
|
|
|
|
|
my $text = <<'END'; |
80
|
|
|
|
|
|
|
This allows you to embed WebChat script in your |
81
|
|
|
|
|
|
|
Perl scripts easily. WebChat is an Expect type |
82
|
|
|
|
|
|
|
language that makes it easy to fetch and |
83
|
|
|
|
|
|
|
manipulate web pages and their forms. See the |
84
|
|
|
|
|
|
|
webchatpp or WWW::Chat man pages for more details |
85
|
|
|
|
|
|
|
END |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |