Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The caller is doingmy $row_hash; $x=0; while($row_hash = $st->fetchrow_hashref) { if($wildCard==1) { foreach(@tables) { my $col; foreach $col(@$_) { $dbReturn{$x}{$col} = $row_has +h->{$col}; $x++; } } } else { foreach(@fieldNames) { $dbReturn{$x}{$_} = $row_hash->{$_}; #print "$dbReturn{$x}{$_}\n"; } } } return $dbReturn;
I have tried putting known data into the {}{} and it does not work. I know the data in $dbReturn is present because if I call it from the module itself everything works fine. Everything is using strict and warnings. If I try to return the data asmy $dbData = $dbFunctions->query($queryString) my $something = $dbData->{}{};
I get the following error apon execution Can't use string ("1/8") as a HASH ref while "strict refs" in use at test.cgi line 14. Here is a data demo datatable for $dbReturnreturn %dbReturn;
| $dbReturn{0} | ||
| $dbReturn{0}{'ID'} | $dbReturn{0}{'Firstname'} | $dbReturn{0}{'Lastname'} |
| 0 | John | Doe |
| $dbReturn{1} | ||
| $dbReturn{1}{'ID'} | $dbReturn{1}{'Firstname'} | $dbReturn{1}{'Lastname'} |
| 1 | Jane | Doe |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Returning Hashes
by cmeyer (Pilgrim) on Jun 03, 2005 at 23:05 UTC | |
|
Re: Returning Hashes
by duff (Parson) on Jun 03, 2005 at 23:10 UTC | |
|
Re: Returning Hashes
by monarch (Priest) on Jun 04, 2005 at 00:36 UTC | |
|
Re: Returning Hashes
by Anonymous Monk on Jun 03, 2005 at 23:15 UTC |