| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::perlimports::Sandbox; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 83 |  |  | 83 |  | 2379 | use strict; | 
|  | 83 |  |  |  |  | 260 |  | 
|  | 83 |  |  |  |  | 2448 |  | 
| 4 | 83 |  |  | 83 |  | 579 | use warnings; | 
|  | 83 |  |  |  |  | 276 |  | 
|  | 83 |  |  |  |  | 3201 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | our $VERSION = '0.000051'; | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 76 |  |  | 76 |  | 32698 | use Data::UUID (); | 
|  | 76 |  |  |  |  | 46543 |  | 
|  | 76 |  |  |  |  | 14805 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | { | 
| 11 |  |  |  |  |  |  | my $du = Data::UUID->new; | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | sub pkg_for { | 
| 14 | 189 |  |  | 189 | 1 | 626 | my $module_name = shift; | 
| 15 | 189 |  |  |  |  | 14844 | my $unique      = 'A' . $du->create_str; | 
| 16 | 189 |  |  |  |  | 1644 | $unique =~ s{-}{}g; | 
| 17 |  |  |  |  |  |  |  | 
| 18 | 188 |  |  |  |  | 2494 | return sprintf( | 
| 19 |  |  |  |  |  |  | 'Local::%s::%s', | 
| 20 |  |  |  |  |  |  | $module_name, | 
| 21 |  |  |  |  |  |  | $unique | 
| 22 |  |  |  |  |  |  | ); | 
| 23 |  |  |  |  |  |  | } | 
| 24 |  |  |  |  |  |  | } | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | sub eval_pkg { | 
| 27 | 99 |  |  | 99 | 1 | 18568 | my $module_name = shift; | 
| 28 | 99 |  |  |  |  | 369 | my $content     = shift; | 
| 29 |  |  |  |  |  |  |  | 
| 30 | 97 |  |  |  |  | 339 | my $pkg = pkg_for($module_name); | 
| 31 |  |  |  |  |  |  |  | 
| 32 | 97 |  |  |  |  | 462 | my $to_eval = <<"EOF"; | 
| 33 |  |  |  |  |  |  | package $pkg; | 
| 34 |  |  |  |  |  |  | $content; | 
| 35 |  |  |  |  |  |  | 1; | 
| 36 |  |  |  |  |  |  | EOF | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | ## no critic (Variables::RequireInitializationForLocalVars) | 
| 39 | 97 |  |  |  |  | 197 | local $@; | 
| 40 |  |  |  |  |  |  | ## no critic (BuiltinFunctions::ProhibitStringyEval,ErrorHandling::RequireCheckingReturnValueOfEval) | 
| 41 | 97 |  |  | 29 |  | 9179 | eval $to_eval; | 
|  | 29 |  |  | 22 |  | 345 |  | 
|  | 29 |  |  | 10 |  | 132 |  | 
|  | 29 |  |  | 7 |  | 1645 |  | 
|  | 23 |  |  |  |  | 523 |  | 
|  | 21 |  |  |  |  | 67 |  | 
|  | 21 |  |  |  |  | 904 |  | 
|  | 10 |  |  |  |  | 558 |  | 
|  | 10 |  |  |  |  | 92 |  | 
|  | 10 |  |  |  |  | 332 |  | 
|  | 7 |  |  |  |  | 68 |  | 
|  | 7 |  |  |  |  | 17 |  | 
|  | 7 |  |  |  |  | 263 |  | 
| 42 |  |  |  |  |  |  |  | 
| 43 | 96 |  |  |  |  | 3210 | my $e = $@; | 
| 44 | 96 |  |  |  |  | 766 | 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.000051 | 
| 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 |