CGI-Compile
view release on metacpan or search on metacpan
lib/CGI/Compile.pm view on Meta::CPAN
return ($package, $name);
}
# define tmp_dir value later on first usage, otherwise all children
# share the same directory when forked
my $tmp_dir;
sub _eval {
my $code = \$_[1];
# we use a tmpdir chmodded to 0700 so that the tempfiles are secure
$tmp_dir ||= File::Spec->catfile(File::Spec->tmpdir, "cgi_compile_$$");
if (! -d $tmp_dir) {
mkdir $tmp_dir or die "Could not mkdir $tmp_dir: $!";
chmod 0700, $tmp_dir or die "Could not chmod 0700 $tmp_dir: $!";
}
my ($fh, $fname) = File::Temp::tempfile('cgi_compile_XXXXX',
UNLINK => 1, SUFFIX => '.pm', DIR => $tmp_dir);
print $fh $$code;
close $fh;
my $sub = do $fname;
( run in 0.565 second using v1.01-cache-2.11-cpan-496ff517765 )