Memory mapping for Perl
Perl XS
Clone or download



File::Map is a module that maps files or anonymous memory into perl variables.

Advantages of memory mapping
  *   Unlike normal perl variables, mapped memory is shared between
      threads or forked processes.

  *   It is an efficient way to slurp an entire file. Unlike for example
      File::Slurp, this module returns almost immediately, loading the
      pages lazily on access. This means you only 'pay' for the parts of
      the file you actually use.

  *   Perl normally never returns memory to the system while running,
      mapped memory can be returned.

Advantages of this module over other similar modules
 Safety and Speed
  This module is safe yet fast. Alternatives are either fast but can cause
  segfaults or loose the mapping when not used correctly, or are safe but
  rather slow. File::Map is as fast as a normal string yet safe.

  It offers a more simple interface targeted at common usage patterns

  *   Files are mapped into a variable that can be read just like any
      other variable, and it can be written to using standard Perl
      techniques such as regexps and "substr".

  *   Files can be mapped using a set of simple functions. No weird
      constants or 6 argument functions.

  *   It will automatically unmap the file when the scalar gets destroyed.
      This works correctly even in multithreaded programs.

  File::Map supports both Unix and Windows.

 Thread synchronization
  It has built-in support for thread synchronization.


To install this module, run the following commands:

	perl Build.PL
	./Build test
	./Build install


After installing, you can find documentation for this module with the
perldoc command.

    perldoc File::Map

You can also look for information at:

    RT, CPAN's request tracker

    AnnoCPAN, Annotated CPAN documentation

    CPAN Ratings

    Search CPAN


Copyright (C) 2008 Leon Timmermans

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.