Re: Problem by pushing a String and a Hash on an array!



pod69@xxxxxxx wrote:
I try to push on an array(global) a string and a hash ->
push(@array,{name => $n_name, hash => \%myhash});

Do you realize that @array only contains one element, i.e. a hash reference?

now i try to read out everything but i have a problems with the array?
I try this to read everything out:

sub println {
for(my $i = 0; $i < scalar(@array) ; $i++ ){
print $array[$i]{name};
my %hash = $array[$i]{hash};
foreach $key ( keys %hash){
print $key." = ".$hash{$key}."\n"
}
}
}

the name gets printed out but not the hash?

If that's all you have to tell us, you run the code without strictures and warnings enabled. Please follow the posting guidelines
http://www.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

by adding

use strict;
use warnings;

to the top of your script, and let Perl tell you what's wrong with your code.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.