Boulder
view release on metacpan or search on metacpan
Boulder/Stream.pm view on Meta::CPAN
}
# utility routine to turn type globs, barewords, IO::File structs, etc into
# filehandles.
sub to_fh {
my ($pack,$thingy,$write) = @_;
return unless $thingy;
return $thingy if defined fileno($thingy);
my $caller;
while (my $package = caller(++$caller)) {
my $qualified_thingy = Symbol::qualify_to_ref($thingy,$package);
return $qualified_thingy if defined fileno($qualified_thingy);
}
# otherwise try to open it as a file
my $fh = Symbol::gensym();
$thingy = ">$thingy" if $write;
open ($fh,$thingy) || croak "$pack open of $thingy: $!";
return \*$fh;
}
( run in 0.740 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )