File: ORTestGlobs.pm

package info (click to toggle)
libobject-remote-perl 0.003004-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 408 kB
  • ctags: 221
  • sloc: perl: 2,365; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 478 bytes parent folder | download | duplicates (5)
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
package ORTestGlobs;
use Moo;

has handle => (is => 'rw');
has valueref => (is => 'ro', default => sub {
  my $body = '';
  return \$body;
});

sub write { my $self = shift; print { $self->handle } @_ }

sub getvalue { ${ $_[0]->valueref } }

sub gethandle {
  open my $fh, '>', $_[0]->valueref
    or die "Unable to open in-memory file: $!\n";
  return $fh;
}

sub getreadhandle {
  open my $fh, '<', $_[1]
    or die "Unable to open in-memory file: $!\n";
  return $fh;
}

1;