Commit | Line | Data |
ed5a8a8e |
1 | package ORTestGlobs; |
2 | use Moo; |
3 | |
4 | has handle => (is => 'rw'); |
5 | has valueref => (is => 'ro', default => sub { |
6 | my $body = ''; |
7 | return \$body; |
8 | }); |
9 | |
10 | sub write { my $self = shift; print { $self->handle } @_ } |
11 | |
12 | sub getvalue { ${ $_[0]->valueref } } |
13 | |
14 | sub gethandle { |
15 | open my $fh, '>', $_[0]->valueref |
16 | or die "Unable to open in-memory file: $!\n"; |
17 | return $fh; |
18 | } |
19 | |
20 | sub getreadhandle { |
21 | open my $fh, '<', $_[1] |
22 | or die "Unable to open in-memory file: $!\n"; |
23 | return $fh; |
24 | } |
25 | |
26 | 1; |