File-Map reviews

cpanratings
 

RSS | Module Info | Add a review of File-Map

File-Map (0.61) ****

This is a well designed module and is nearly always preferable to the classic Sys::Mmap. Unlike Sys::Mmap, it will clean up mappings when they are no longer needed because all variables referencing them have gone out of scope.

A couple minor issues with File::Map:

* File::Map contains partial interfaces to msync/mlock/mprotect/madvise. I feel that these interfaces should be in separate modules, not bundled together with a file mapping module since they can be useful even when you aren't directly using mmap().

* There is no way to create MAP_FIXED mappings (although you generally don't need this).

* The dependency tree seems slightly excessive.

Although not an issue with this module, as it says in the documentation you should be aware that there is a bug in perl versions before 5.17.5 where regular expressions can read one byte past the end of a string. This can segfault your perl process if you create mappings that are exact multiples of your page size (and your OS doesn't create adjacent mappings):

$ uname -a

OpenBSD saturn 5.1 GENERIC#181 amd64

$ perl -E 'say $^V'

v5.12.2

$ perl -MFile::Map -e 'File::Map::map_file my $str, "/dev/zero", "<", 0, 4096; $str =~ /.$/'

Segmentation fault (core dumped)

Doug Hoyte - 2013-10-22T21:49:48 (permalink)

1 out of 2 found this review helpful. Was this review helpful to you?  Yes No

File-Map (0.61) *

Save yourself a pile of prereqs[1] and use Sys::Mmap instead.

[1] deps.cpantesters.org/?module=File%3A%...

seano - 2013-10-18T05:41:23 (permalink)

1 out of 2 found this review helpful. Was this review helpful to you?  Yes No

File-Map (0.23) ****

Traditionally, programs read information from a file by opening a file handle, reading data into memory, then closing the file handle. This module takes a different approach: it provides a scalar variable that magically corresponds to a file's content on disk without reading any new data into memory.

If you find yourself working with files of large or unknown size, this module saves you having to worry about the memory that perl might allocate.

Behind the scenes, the module uses mmap on Unix to do its magic. The module uses similar facilities on Windows and VMS, making it portable to most platforms that Perl developers often use.

I like this module because it combines the easiness of File::Slurp (or setting $/ to undef for those who like minimal dependencies) and the efficiency of other interfaces to mmap, such as Sys::Mmap, along with the benefit of better portability.

Tom Hukins - 2010-03-08T07:51:45 (permalink)

6 out of 6 found this review helpful. Was this review helpful to you?  Yes No

File-Map (0.19) ****

The import interface is wonky (why make people write a bunch of ":foo"?), but this module is heading in the right direction.

Pista Palo - 2009-11-08T21:41:03 (permalink)

4 out of 9 found this review helpful. Was this review helpful to you?  Yes No