http://www.perlmonks.org?node_id=11122659


in reply to Re^5: Memory mapped file questions
in thread Memory mapped file questions

I thought it could do it like c++ or c# does, therefore you confim perl is not able to do that ?

Replies are listed 'Best First'.
Re^7: Memory mapped file questions
by Corion (Pope) on Oct 10, 2020 at 18:47 UTC

    C++ or C# programs are also not able to access this memory mapped file. If it does not have a name, you need to pass the file handle to the process that is supposed to read from the file by inheriting the filehandle in a child process. Perl can easily inherit file handles, but then you need to launch the process for reading the data from your main program.

    You will need to learn more about the usage of memory mapped files and IPC in general. Your approach makes things far harder than necessary, or you need to state much more about why you need to use a memory mapped file.

      but the name of file exist and is Test , i run a MSDN example in C# and in C++ , in msdn i have first program create a memory mapped file , second program (i dont run a second program by main program), read perfect a string memory mapped file , therefore i simply want do it with perl. Why i do this ? simply i want understand how work a file mapped, and look how is complicated or not , in many program language , but if you confirm perl don't do it because for perl is necessary have a real file in HDD , no problem

        If that works, then you can likely do the same in Perl. But as I don't know your C++ code to access that memory mapped file, you will have to find out yourself what API calls C# uses and how to access these from Perl.

        CPAN has some modules for memory mapping files, see Mmap, maybe you find something there. Or alternatively, maybe you can open the file just as a file, see open. In any case, you will have to find out what works for you, because I'm not going to learn what Windows API the C# code uses.