Alt-Math-Prime-FastSieve-Inline
view release on metacpan or search on metacpan
inc/Capture/Tiny.pm view on Meta::CPAN
727374757677787980818283848586878889909192#--------------------------------------------------------------------------#
# filehandle manipulation
#--------------------------------------------------------------------------#
sub
_relayer {
my
(
$fh
,
$layers
) =
@_
;
# _debug("# requested layers (@{$layers}) for @{[fileno $fh]}\n");
my
%seen
= (
unix
=> 1,
perlio
=> 1 );
# filter these out
my
@unique
=
grep
{ !
$seen
{
$_
}++ }
@$layers
;
# _debug("# applying unique layers (@unique) to @{[fileno $fh]}\n");
binmode
(
$fh
,
join
(
":"
,
":raw"
,
@unique
));
}
sub
_name {
my
$glob
=
shift
;
no
strict
'refs'
;
## no critic
return
*{
$glob
}{NAME};
}
sub
_open {
open
$_
[0],
$_
[1] or Carp::confess
"Error from open("
.
join
(
q{, }
,
@_
) .
"): $!"
;
inc/Capture/Tiny.pm view on Meta::CPAN
107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
if
(
defined
$dup
{stdin}) {
_open \
*STDIN
,
"<&="
.
fileno
(
$dup
{stdin});
# _debug( "# restored proxy STDIN as " . (defined fileno STDIN ? fileno STDIN : 'undef' ) . "\n" );
}
else
{
_open \
*STDIN
,
"<"
. File::Spec->devnull;
# _debug( "# proxied STDIN as " . (defined fileno STDIN ? fileno STDIN : 'undef' ) . "\n" );
_open
$dup
{stdin} = IO::Handle->new,
"<&=STDIN"
;
}
$proxies
{stdin} = \
*STDIN
;
binmode
(STDIN,
':utf8'
)
if
$] >= 5.008;
}
if
( !
defined
fileno
STDOUT ) {
$proxy_count
{stdout}++;
if
(
defined
$dup
{stdout}) {
_open \
*STDOUT
,
">&="
.
fileno
(
$dup
{stdout});
# _debug( "# restored proxy STDOUT as " . (defined fileno STDOUT ? fileno STDOUT : 'undef' ) . "\n" );
}
else
{
_open \
*STDOUT
,
">"
. File::Spec->devnull;
# _debug( "# proxied STDOUT as " . (defined fileno STDOUT ? fileno STDOUT : 'undef' ) . "\n" );
_open
$dup
{stdout} = IO::Handle->new,
">&=STDOUT"
;
}
$proxies
{stdout} = \
*STDOUT
;
binmode
(STDOUT,
':utf8'
)
if
$] >= 5.008;
}
if
( !
defined
fileno
STDERR ) {
$proxy_count
{stderr}++;
if
(
defined
$dup
{stderr}) {
_open \
*STDERR
,
">&="
.
fileno
(
$dup
{stderr});
# _debug( "# restored proxy STDERR as " . (defined fileno STDERR ? fileno STDERR : 'undef' ) . "\n" );
}
else
{
_open \
*STDERR
,
">"
. File::Spec->devnull;
# _debug( "# proxied STDERR as " . (defined fileno STDERR ? fileno STDERR : 'undef' ) . "\n" );
_open
$dup
{stderr} = IO::Handle->new,
">&=STDERR"
;
}
$proxies
{stderr} = \
*STDERR
;
binmode
(STDERR,
':utf8'
)
if
$] >= 5.008;
}
return
%proxies
;
}
sub
_unproxy {
my
(
%proxies
) =
@_
;
# _debug( "# unproxying: " . join(" ", keys %proxies) . "\n" );
for
my
$p
(
keys
%proxies
) {
$proxy_count
{
$p
}--;
# _debug( "# unproxied " . uc($p) . " ($proxy_count{$p} left)\n" );
( run in 0.300 second using v1.01-cache-2.11-cpan-5f2e87ce722 )