Sorry for OT'ing your post, but I thought an example of mmap on *nix, tested in Linux, could be useful for those lucky linux users:

use strict; use warnings; use Fcntl; use Inline C => Config => LIBS => '', BUILD_NOISY => 1; use Inline C => <<'END_OF_C_CODE'; #include <sys/mman.h> #include <stdio.h> #include <errno.h> int unmap_region(void *m, int sz){ if( munmap(m, sz) != 0 ){ fprintf(stderr, "unmap_region() : error, call to munmap() has +failed for memory address %p and size %ld : %s\n", m, sz, strerror(er +rno)); return 0; // failed } return 1; // success } void *map_region(int fd, int sz){ char *map = (char *)mmap(NULL, sz, PROT_READ|PROT_WRITE, MAP_F +ILE|MAP_SHARED, fd, 0); if (map == MAP_FAILED){ fprintf(stderr, "map has failed for size %ld : %s\n", sz, stre +rror(errno)); return (void *)NULL; // failed } return map; // success } END_OF_C_CODE my $test_file = 'test_mmap.bin'; sysopen(my $fh, $test_file, O_RDWR|O_CREAT|O_TRUNC) or die "can't open file '$test_file' : $!"; binmode $fh; my $size = 4096; my $addr = map_region(fileno($fh), $size) or die "mmap failed!!: $^E "; my $test_str = "Hello Linux mmap!"; syswrite($fh, $test_str); unmap_region($addr, $size) or die "fail to unmap"; close($fh); open($fh, '<', $test_file) or die "failed to open file '$test_file'/2, + $!"; my $contents; { local $/ = undef; $contents = <$fh> } close $fh; print "Sucess, contents of the mmap'ed file '$test_file':\n${contents} +\n--end contents.\n";

In reply to Linux example of mmap by bliako
in thread what is exactly HANDL is by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.