Thanx for above Re^4, RobinV. This contained the missing info & confirmed the missing reader to be my suspected kitten, ahem - cat :). Btw. did you notice that your indenting didn't quite survive pasting?

Observation: It looks to me like $mmap isn't synced to file (or maybe even to the mmapped memory?) if the length changed, even if the new value _remains_ usable within the script. Modify your writer similar to the scrap below to make it work, but choose something more sensible than my substring mess.

# WORKS -- but it's suddenly quite slow due to synchronous sync :) for(my $i=0;$i<105;++$i) { substr($mmap,0,2) = substr($i . (" "x20) ,0,2); sync($mmap,1); }

Question: isn't this a bug / incomplete documentation? IMHO there should be a way to at least optionally turn on a warning or error somehow for this case, otherwise that's a good place for hard-to-find bugs. (I also forwarded the URL for this thread to the module's author for a rain check. Maybe I missed something when skimming the module's documentation)

Maybe worth a check: There are more mmap modules on CPAN besides File::Map (Cache::FastMmap, Sys::Mmap + ::Simple, IPC::Mmap) some of which may turn out to be less rigid in assignments, maybe allowing implied remapping, padding or substring-insertion for shorter assignments.


In reply to Re: mmap in Perl? by jakobi
in thread mmap in Perl? by RobinV

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.