File::Map - Memory mapping made simple and safe.


NAME

File::Map - Memory mapping made simple and safe.

Back to Top


VERSION

Version 0.25

Back to Top


SYNOPSIS

 use File::Map 'map_file';
 
 map_file my $map, $filename;
 if ($map ne "foobar") {
     $map =~ s/bar/quz/g;
     substr $map, 1024, 11, "Hello world";
 }

Back to Top


DESCRIPTION

File::Map maps files or anonymous memory into perl variables.

Advantages of memory mapping

Advantages of this module over other similar modules

Back to Top


FUNCTIONS

Mapping

The following functions for mapping a variable are available for exportation.

Auxiliary

Locking

These locking functions provide locking for threads for the mapped region. The mapped region has an internal lock and condition variable. The condition variable functions(wait_until, notify, broadcast) can only be used inside a locked block. If your perl has been compiled without thread support the condition functions will not be available.

CONSTANTS

PROT_NONE, PROT_READ, PROT_WRITE, PROT_EXEC, MAP_ANONYMOUS, MAP_SHARED, MAP_PRIVATE, MAP_ANON, MAP_FILE

These constants are used for sys_map. If you think you need them your mmap manpage will explain them, but in most cases you can skip sys_map altogether.

Back to Top


EXPORTS

All previously mentioned functions are available for exportation, but none are exported by default. Some functions may not be available on your OS or your version of perl as specified above. A number of tags are defined to make importation easier.

Back to Top


DIAGNOSTICS

In this overview %f is the name of the function that produced the error, and %e is some error from your OS.

Exceptions

Warnings

Back to Top


DEPENDENCIES

This module depends on perl 5.8 and Readonly.

Back to Top


PITFALLS

On perl versions lower than 5.11.5 many string functions including substr are limited to 32bit logic, even on 64bit architectures. Effectively this means you can't use them on strings bigger than 2GB. If you are working with such large files, I strongly recommend upgrading to 5.12.

This module assumes the file is binary data and doesn't do any encoding or newline transformation for you. Most importantly this means that:

You probably don't want to use > as a mode. This does not give you reading permissions on many architectures, resulting in segmentation faults when trying to read a variable (confusingly, it will work on some others like x86).

Back to Top


BUGS AND LIMITATIONS

As any piece of software, bugs are likely to exist here. Bug reports are welcome.

Please report any bugs or feature requests to bug-file-map at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

Back to Top


SEE ALSO

Back to Top


AUTHOR

Leon Timmermans, <leont at cpan.org>

Back to Top


SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc File::Map

You can also look for information at:

Back to Top


COPYRIGHT AND LICENSE

Copyright 2008, 2009, 2010 Leon Timmermans, all rights reserved.

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

Back to Top

 File::Map - Memory mapping made simple and safe.