in reply to Re^4: Tk ::TableMatrix
in thread Tk ::TableMatrix
YOUR REAL PROBLEM is you don't understand the data structure involved, it's already there in the hash, all you need to do is pull it out. Read "perldoc perlreftut" and see References quick reference.
The following code should show you what's up. Don't let the name $arrayVar throw you off, it's actually an hashref for %$arrayVar.
#!/usr/bin/perl my $arrayVar = {}; # this is actually a hashref print "Filling Array...\n"; my ($rows,$cols) = (10, 10); foreach my $row (0..($rows-1)){ foreach my $col (0..($cols-1)){ $arrayVar->{"$row,$col"} = 2*$row + 3*$col; } } foreach my $key (sort keys %$arrayVar){ print "$key -> ",$$arrayVar{$key},"\n"; #or # print "$key -> ",$arrayVar->{$key},"\n"; }
|
|---|