With File::Map your mappings will be unmapped automatically:
File::Map::map_file my $str, "/etc/passwd", '<';
die "Something bad happened!";
## Mapping has been released
Other issues with Sys::Mmap:
* It is not as portable as File::Map which also supports windows.
* The synopsis seems to be wrong. You have to do "new Sys::Mmap", not "new Mmap". But don't use this interface since it doesn't seem to be possible to clean up mappings after they are no longer needed.
* There is no way to create MAP_FIXED mappings (although you generally don't need this).
Although not an issue with this module, 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):
Simple, works as advertised, wish it were core. It's great for mapping in a huge chunk of text and screaming through it with a regex. I haven't benchmarked it, but this is almost certainly much faster than slurping a file when you need read-only access.