File Coverage

blib/lib/Lisp/Subr/Perl.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Lisp::Subr::Perl;
2              
3             # Make many perl functions available in the lisp envirionment
4              
5 1     1   5 use strict;
  1         2  
  1         40  
6 1     1   5 use vars qw($DEBUG $VERSION);
  1         2  
  1         91  
7              
8             $VERSION = sprintf("%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/);
9              
10 1     1   6 use Lisp::Symbol qw(symbol);
  1         1  
  1         293  
11              
12             my @code;
13              
14             # Perl builtins that does take zero arguments
15             for (qw(time times getlogin getppid fork wait)) {
16             push(@code, qq(symbol("$_")->function(sub { $_ });\n));
17             }
18              
19             # Perl builtins that take one optional argument
20             for (qw(sin cos rand srand exp log sqrt int hex oct abs ord chr
21             ucfirst lcfirst uc lc quotemeta caller reset exit
22             umask chdir chroot readlink rmdir getpgrp
23             localtime gmtime alarm sleep
24             require stat length chop chomp defined undef study pos
25             -r -w -x -o -R -W -X -O -e -z -s -f -d -l -p -S -b -c
26             -t -u -g -k -u -g -k -T -B -M -A -C
27             ))
28             {
29             push(@code, qq(symbol("$_")->function(sub { \@_==0?$_:$_ \$_[0] });\n));
30             }
31              
32             print join("", @code) if $DEBUG;
33             eval join("", @code);
34             die $@ if $@;
35              
36             # some additional stuff
37             symbol("perl-eval")->function(sub { eval $_[0] });
38              
39             1;