in reply to Re^2: Map a string to an array
in thread Map a string to an array

Further to runrig's replies:
It's important to understand at each step how the structures of the hash and arrays are changing and evolving. Here's a kind of "running commentary" on that evolution, and a possible way to access and print what you want. Liberal use of data structure (for that's what you're dealing with; see perldsc) dump statements can be very enlightening about the changes that are going on. (And BTW, congratulations on being able to work with a system having at least 128 Terabytes of system RAM — or do I misinterpret the reference address of 0x7ffafc013bf8?)

>perl -wMstrict -MData::Dump -le "my %mapp; my @arr = qw(R T HH M); ;; $mapp{k} = \@arr; my @val = $mapp{k}; ;; dd \%mapp; dd \@val; ;; print join q{,}, @{$mapp{k}}; ;; push @val, 'RBB'; dd \@val; ;; $mapp{k} = \@val; dd \%mapp; ;; print join q{,}, @{$mapp{k}}; print join q{,}, @{ $mapp{k}->[0] }, $mapp{k}->[1]; " { k => ["R", "T", "HH", "M"] } [["R", "T", "HH", "M"]] R,T,HH,M [["R", "T", "HH", "M"], "RBB"] { k => [["R", "T", "HH", "M"], "RBB"] } ARRAY(0x1e14b3c),RBB R,T,HH,M,RBB

Replies are listed 'Best First'.
Re^4: Map a string to an array
by BrowserUk (Patriarch) on Nov 02, 2013 at 10:23 UTC
    (And BTW, congratulations on being able to work with a system having at least 128 Terabytes of system RAM — or do I misinterpret the reference address of 0x7ffafc013bf8?)

    With virtual memory, heap does not have to be contiguous.

    This C program allocates a single page of memory starting at the 4GB base address and then doubles the base address each time until it fails:

    #define _CRT_SECURE_NO_WARNINGS #include <windows.h> #include <conio.h> #include <time.h> #include "debug.h" #include "mytypes.h" int main( int argc, char **argv ) { U64 size = 4096, base = 4294967296; char *p; while( 1 ) { char *p = VirtualAllocEx( GetCurrentProcess(), (VOID*)base, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE ); DIEIF( p == NULL ); printf( "4k allocated at:%16p (%30I64d)\n", p, 0+p ); _getch(); base *= 2; } exit( 0 ); }

    I only have 8GB of ram, but the last time the above succeeds:

    C:\test>vmem3 4k allocated at:0000000100000000 ( 4294967296) 4k allocated at:0000000200000000 ( 8589934592) 4k allocated at:0000000400000000 ( 17179869184) 4k allocated at:0000000800000000 ( 34359738368) 4k allocated at:0000001000000000 ( 68719476736) 4k allocated at:0000002000000000 ( 137438953472) 4k allocated at:0000004000000000 ( 274877906944) 4k allocated at:0000008000000000 ( 549755813888) 4k allocated at:0000010000000000 ( 1099511627776) 4k allocated at:0000020000000000 ( 2199023255552) 4k allocated at:0000040000000000 ( 4398046511104) [ 1916] vmem3.c(18):p == NULL failed with error 87 (The parameter is incorrect)

    It allocated a page at a base address that is 4096 GB. At that point the process is only using 668k of memory.

    4096GB is 2^42 which reflects that my 64-bit processor actually only has a 44-bit virtual address space.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.