| 1: | <?php |
| 2: | declare(strict_types=1); |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | class Perl_Module extends Module_Skeleton |
| 20: | { |
| 21: | public $exportedFunctions; |
| 22: | |
| 23: | public function __construct() |
| 24: | { |
| 25: | parent::__construct(); |
| 26: | $this->exportedFunctions = array( |
| 27: | '*' => PRIVILEGE_ALL, |
| 28: | 'get_modules' => PRIVILEGE_SITE | PRIVILEGE_USER |
| 29: | |
| 30: | ); |
| 31: | } |
| 32: | |
| 33: | public function get_modules() |
| 34: | { |
| 35: | $cmd = '/usr/bin/perl -e \'use File::Find; |
| 36: | foreach $start (@INC) { find(\&modules, $start); } |
| 37: | sub modules { |
| 38: | if (-d && /^[a-z]/) { |
| 39: | $File::Find::prune = 1; return; } |
| 40: | return unless /\.pm$/; |
| 41: | my $filename = "$File::Find::dir/$_"; |
| 42: | $filename =~ s!^$start/!!; |
| 43: | $filename =~ s!\.pm\$!!; |
| 44: | $filename =~ s!/!::!g; |
| 45: | print "$filename\n"; |
| 46: | }\' 2>&1'; |
| 47: | $proc = Util_Process_Sudo::exec($cmd); |
| 48: | $perlArray = explode("\n", $proc['output']); |
| 49: | sort($perlArray); |
| 50: | |
| 51: | return $perlArray; |
| 52: | } |
| 53: | |
| 54: | |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | |
| 60: | |
| 61: | |
| 62: | |
| 63: | public function get_pod($module) |
| 64: | { |
| 65: | $proc = Util_Process_Safe::exec('/usr/bin/perldoc %s', array($module)); |
| 66: | $perlDoc = $proc['output']; |
| 67: | |
| 68: | return $perlDoc; |
| 69: | } |
| 70: | |
| 71: | |
| 72: | |
| 73: | |
| 74: | |
| 75: | |
| 76: | |
| 77: | |
| 78: | public function version() |
| 79: | { |
| 80: | $cache = \Cache_Global::spawn(); |
| 81: | $key = 'perl.version'; |
| 82: | if (false === ($version = $cache->get($key))) { |
| 83: | $version = array_get(\Util_Process::exec(['/usr/bin/perl', '-e', 'printf "%vd", $^V;']), 'output'); |
| 84: | $cache->set($key, $version); |
| 85: | } |
| 86: | |
| 87: | return $version; |
| 88: | } |
| 89: | } |