Thanks Stevieb for the response .. and everyone else .. But somehow it does not work .. or may be i am not doing it right If i print the reg_map variable using the following code

for $i ( 0 .. $page_counter-1 ) { print " ###### HI $i #### \n"; eval ( "\$Total_Size = \$\#reg_map${i}"); print " Total Size = $Total_Size\n"; for $j1 ( 0 .. $Total_Size ) { eval ("\$Num_elements_in_row = \@\{\$reg_map${i}\[\$j1\]\}"); print " Num_elements_in_row $j1 is = $Num_elements_in_row\n"; for $j3 ( 0 .. $Num_elements_in_row ) { eval("print \"Bit 1 :\$i:\$j1:\$j3 is \$reg_map${i}\[\$j1\]\[\$j +3\]\n\""); } } }

I get the following display

Total Size = 80

Num_elements_in_row 0 is = 3

Bit 1 :0:0:0 is NONE

Bit 1 :0:0:1 is NONE

Bit 1 :0:0:2 is NONE

Bit 1 :0:0:3 is

Num_elements_in_row 1 is = 4

Bit 1 :0:1:0 is TEMP

Bit 1 :0:1:1 is 0

Bit 1 :0:1:2 is .

Bit 1 :0:1:3 is 1

Bit 1 :0:1:4 is

I used Store as follows

 store(\@reg_map, 'file.ext');my $aref = retrieve('file.ext');

When i print aref using the code below

for $i ( 0 .. $page_counter-1 ) { print " ###### HI $i #### \n"; eval ( "\$Total_Size = \$\#aref${i}"); print " Total Size = $Total_Size\n"; for $j1 ( 0 .. $Total_Size ) { eval ("\$Num_elements_in_row = \@\{\$aref${i}\[\$j1\]\}"); print " Num_elements_in_row $j1 is = $Num_elements_in_row\n"; for $j3 ( 0 .. $Num_elements_in_row ) { eval("print \"Bit 2 :\$i:\$j1:\$j3 is \$aref${i}\[\$j1\]\[\$j3\] +\n\""); } } }

I get the following

###### HI 0 ####

Total Size = -1

###### HI 1 ####

Total Size = -1

I Also tried using JSON as follows

open my $wfh, '>', 'file1.ext' or die "can't open file for writing: $!"; print $wfh encode_json(\@reg_map); close $wfh; open my $fh, '<', 'file.ext' or die "can't open file for reading: $!"; my @aref = decode_json(<$fh>);

But i get an error at the last line :

malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "pst0\x{4}\x{8}\x{8}1...") at perl_script.pl line 100, <$fh> line 1.

Any thoughts on this ..


In reply to Re^2: Writing indexed arrays in to an file and then retrieved by perlmuser
in thread Writing indexed arrays in to an file and then retrieved by perlmuser

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.