1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
package App::PRT::Collector::FileHandle;
use strict;
use warnings;
use File::Temp qw(tempdir tempfile);
sub new {
my ($class, $input_fh) = @_;
bless {
input_fh => $input_fh,
}, $class;
}
sub collect {
my ($self) = @_;
my $input_fh = $self->{input_fh};
my $content = do { local $/; <$input_fh> };
my $dir = tempdir( CLEANUP => 1 );
my ($fh, $file) = tempfile('prt-XXXX', DIR => $dir, SUFFIX => '.pm');
$self->{dir} = $dir;
$self->{file} = $file;
print $fh $content;
close $fh;
[ $file ];
}
1;
|