Hi All,

I am trying to declare variables(hash ref)  dynamically in a loop

I wanna use the name of hash ref as the value of string.

For eg:

             my $i=0;
              foreach my $k ( sort keys  %$headers) {
                     $$i={};    >>>>>>> creating hash ref with the value 
of $i i,e hash name should be $0
                       print "> ref($$i) <";
                       $$i{$k} = $rows[$i];
                        push (@input_data, $$i);
                      $i++;
            }


On a whole I am trying to create hash ref data-structures and finally want 

to populate in an array.
but the program does'nt allow me to declare a hash like this       $$i={}; 

Throws an error "Modification of a read-only value attempted "

Also tried to use hash rather than hash ref

     34         my $i=0;
     35         my $x=1;
     36         foreach my $k ( sort keys  %$headers) {
     37                  %$x=();   #>> used hash instead
     38 #                print "key: $k \n";
     39                  $$x{$k} = $rows[$i];
     40                  print "Now Assigned: $$x{$k} : Org is $rows[$i] 
>>>>>>>>>>>>>>>>>>> $i <<\n";
     41                  $i++;
     42         }
     43                  print ">>>>>", Dumper(%$x),"<<<<<<\n"; exit;  # 
THIS DOESNT HAVE THE HASH VALUES AT ALL
     44                  push (@input_data, \%$x);$x++;



Please advice
Thanks & Regards
Neetee


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This is a PRIVATE message. If you are not the intended recipient, please 
delete without copying and kindly advise us by e-mail of the mistake in 
delivery. NOTE: Regardless of content, this e-mail shall not operate to 
bind CSC to any order or other contract unless pursuant to explicit 
written agreement or government initiative expressly permitting the use of 
e-mail for such purpose.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Reply via email to