map_handle#
Attach an already-open filehandle to a scalar as a memory map.
תקציר#
open my $fh, '<:raw', $filename;
map_handle my $map, $fh;
map_handle my $map, $fh, '+<', $offset, $length;
ארגומנטים#
$lvalue- scalar to receive the mapping.$filehandle- a real filehandle. Scalar-string handles and tied handles are rejected.$mode- defaults to'<'. Same accepted values asmap_file.$offset,$length- same meaning and defaults asmap_file.
דוגמאות#
Map the tail of a log file:
open my $fh, '<:raw', '/var/log/syslog' or die $!;
my $size = -s $fh;
map_handle my $tail, $fh, '<', $size - 4096, 4096;
מקרי קצה#
The filehandle must be binary. Encoding layers like
:utf8or:crlfcausemap_handleto reject the handle.The handle must refer to a regular file, block device, or character device. Pipes and sockets cannot be mapped.
The handle stays valid after the call; closing it does not invalidate the mapping.
הבדלים מן ה-upstream#
Fully compatible with upstream File::Map 0.71.
ראו גם#
map_file- take a filename instead of a filehandle.sys_map- pass rawmmap(2)flags directly.unmap- release the mapping before scope exit.