File: FileHandle.pm

package info (click to toggle)
prt 0.22-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 404 kB
  • sloc: perl: 1,185; makefile: 3
file content (32 lines) | stat: -rw-r--r-- 561 bytes parent folder | download | duplicates (3)
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;