48
|
2 |
0 |
32 |
$cache{$key} || do {
require File::Map;
'File::Map'->VERSION('0.38');
require PerlIO::Layers;
require Scalar::Util;
croak('Handle not mappable') unless PerlIO::Layers::query_handle($fh, 'mappable');
my $self = bless({'key', $key, 'mmap', undef}, $class);
my $tell = tell $fh;
if ($tell < 0) {
croak("Cannot tell() file position: $!");
};
File::Map::map_handle($self->{'mmap'}, $fh, '<', $tell);
File::Map::advise($self->{'mmap'}, 'sequential');
&Scalar::Util::weaken($cache{$key} = $self);
$self
} |