line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Language::LispPerl::CoreBindings; |
2
|
|
|
|
|
|
|
$Language::LispPerl::CoreBindings::VERSION = '0.006'; |
3
|
6
|
|
|
6
|
|
22
|
use strict; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
167
|
|
4
|
6
|
|
|
6
|
|
23
|
use warnings; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
1767
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Language::LispPerl::CoreBindings - Perl functions binded from core.clp |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head2 In lisp: |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
(require "core.clp") |
15
|
|
|
|
|
|
|
( println (. env "USER") ) |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Preloaded methods go here. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# file |
22
|
|
|
|
|
|
|
sub print { |
23
|
0
|
|
|
0
|
0
|
0
|
print @_; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub openfile { |
27
|
2
|
|
|
2
|
0
|
2
|
my $file = shift; |
28
|
2
|
|
|
|
|
3
|
my $cb = shift; |
29
|
2
|
|
|
|
|
2
|
my $fh; |
30
|
2
|
|
|
|
|
199
|
open $fh, $file; |
31
|
2
|
|
|
|
|
4
|
&{$cb}($fh); |
|
2
|
|
|
|
|
6
|
|
32
|
2
|
|
|
|
|
49
|
close $fh; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub puts { |
36
|
1
|
|
|
1
|
0
|
2
|
my $fh = shift; |
37
|
1
|
|
|
|
|
1
|
my $str = shift; |
38
|
1
|
|
|
|
|
12
|
print $fh $str; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub readline { |
42
|
1
|
|
|
1
|
0
|
3
|
my $fh = shift; |
43
|
1
|
|
|
|
|
23
|
return <$fh>; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub readlines { |
47
|
0
|
|
|
0
|
0
|
|
my $file = shift; |
48
|
0
|
|
|
|
|
|
my $fh; |
49
|
0
|
|
|
|
|
|
open $fh, "<$file"; |
50
|
0
|
|
|
|
|
|
my @lines = <$fh>; |
51
|
0
|
|
|
|
|
|
close $fh; |
52
|
0
|
|
|
|
|
|
return join( "\n", @lines ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub file_exists { |
56
|
0
|
|
|
0
|
0
|
|
my $file = shift; |
57
|
0
|
|
|
|
|
|
return \( -e $file ); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# lib search path |
61
|
|
|
|
|
|
|
sub use_lib { |
62
|
0
|
|
|
0
|
0
|
|
my $path = shift; |
63
|
0
|
|
|
|
|
|
unshift @INC, $path; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub gen_name { |
67
|
0
|
|
|
0
|
0
|
|
return "gen-" . rand; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# regexp |
71
|
|
|
|
|
|
|
sub match { |
72
|
0
|
|
|
0
|
0
|
|
my $regexp = shift; |
73
|
0
|
|
|
|
|
|
my $str = shift; |
74
|
0
|
|
|
|
|
|
my @m = ( $str =~ qr($regexp) ); |
75
|
0
|
|
|
|
|
|
return \@m; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub get_env { |
79
|
0
|
|
|
0
|
0
|
|
my $name = shift; |
80
|
0
|
|
|
|
|
|
return $ENV{$name}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |