line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::perlimports::Sandbox; |
2
|
|
|
|
|
|
|
|
3
|
83
|
|
|
83
|
|
2488
|
use strict; |
|
83
|
|
|
|
|
231
|
|
|
83
|
|
|
|
|
2550
|
|
4
|
83
|
|
|
83
|
|
537
|
use warnings; |
|
83
|
|
|
|
|
234
|
|
|
83
|
|
|
|
|
3124
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.000050'; |
7
|
|
|
|
|
|
|
|
8
|
76
|
|
|
76
|
|
33681
|
use Data::UUID (); |
|
76
|
|
|
|
|
47634
|
|
|
76
|
|
|
|
|
14673
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
{ |
11
|
|
|
|
|
|
|
my $du = Data::UUID->new; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub pkg_for { |
14
|
189
|
|
|
189
|
1
|
632
|
my $module_name = shift; |
15
|
189
|
|
|
|
|
15798
|
my $unique = 'A' . $du->create_str; |
16
|
189
|
|
|
|
|
1354
|
$unique =~ s{-}{}g; |
17
|
|
|
|
|
|
|
|
18
|
188
|
|
|
|
|
2582
|
return sprintf( |
19
|
|
|
|
|
|
|
'Local::%s::%s', |
20
|
|
|
|
|
|
|
$module_name, |
21
|
|
|
|
|
|
|
$unique |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub eval_pkg { |
27
|
99
|
|
|
99
|
1
|
20703
|
my $module_name = shift; |
28
|
99
|
|
|
|
|
348
|
my $content = shift; |
29
|
|
|
|
|
|
|
|
30
|
97
|
|
|
|
|
333
|
my $pkg = pkg_for($module_name); |
31
|
|
|
|
|
|
|
|
32
|
97
|
|
|
|
|
487
|
my $to_eval = <<"EOF"; |
33
|
|
|
|
|
|
|
package $pkg; |
34
|
|
|
|
|
|
|
$content; |
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
EOF |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
## no critic (Variables::RequireInitializationForLocalVars) |
39
|
97
|
|
|
|
|
204
|
local $@; |
40
|
|
|
|
|
|
|
## no critic (BuiltinFunctions::ProhibitStringyEval,ErrorHandling::RequireCheckingReturnValueOfEval) |
41
|
97
|
|
|
29
|
|
9505
|
eval $to_eval; |
|
29
|
|
|
22
|
|
341
|
|
|
29
|
|
|
10
|
|
117
|
|
|
29
|
|
|
7
|
|
1524
|
|
|
23
|
|
|
|
|
599
|
|
|
21
|
|
|
|
|
59
|
|
|
21
|
|
|
|
|
1128
|
|
|
10
|
|
|
|
|
649
|
|
|
10
|
|
|
|
|
72
|
|
|
10
|
|
|
|
|
321
|
|
|
7
|
|
|
|
|
60
|
|
|
7
|
|
|
|
|
20
|
|
|
7
|
|
|
|
|
266
|
|
42
|
|
|
|
|
|
|
|
43
|
96
|
|
|
|
|
3200
|
my $e = $@; |
44
|
96
|
|
|
|
|
849
|
return $e; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# ABSTRACT: Internal Tools for perlimports |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=encoding UTF-8 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
App::perlimports::Sandbox - Internal Tools for perlimports |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 VERSION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
version 0.000050 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 pkg_for( $string ) |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Returns a random module/package name, which can be used to eval arbitrary code. |
68
|
|
|
|
|
|
|
Requires the name of the module which will be imported into the package to be |
69
|
|
|
|
|
|
|
created. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 eval_pkg( $module_name, $pkg_content ) |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Takes a module name and content to eval. Returns the contents of C<$@>. So, if |
74
|
|
|
|
|
|
|
it returns true, the C<eval> failed. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Returns a random module/package name, which can be used to eval arbitrary code. |
77
|
|
|
|
|
|
|
Requires the name of the module which will be imported into the package to be |
78
|
|
|
|
|
|
|
created. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 AUTHOR |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Olaf Alders <olaf@wundercounter.com> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This software is copyright (c) 2020 by Olaf Alders. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
89
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |