Return keys from $db->DataHash directly into an array

Is there anyway to pass just the keys of a data hash directly into an
array or is it necessary to do something like this?

$db->Sql("SELECT * FROM Groups");
$db->FetchRow();
%hash = $db->DataHash;
foreach $key (keys %hash) {
[at] fields[$i]=$key;
print "my field $fields[$i]\n";
$i++;

}


TIA

dan
dtshedd [ So, 16 September 2007 17:56 ] [ ID #1821861 ]

Re: Return keys from $db->DataHash directly into an array

dtshedd [at] yahoo.com wrote:
> Is there anyway to pass just the keys of a data hash directly into an
> array or is it necessary to do something like this?

Please identify the name of the module in question (Win32::ODBC, in this
case).

> $db->Sql("SELECT * FROM Groups");
> $db->FetchRow();
> %hash = $db->DataHash;
> foreach $key (keys %hash) {
> [at] fields[$i]=$key;

Please read perlfaq4, "What is the difference between $array[1] and
[at] array[1]?"

In any case, this is a data structure question, not a module-specific
question. Try `` [at] fields = keys %hash'' after you've read the FAQs.

Regards,
Mike
Mike Pomraning [ So, 16 September 2007 22:37 ] [ ID #1821865 ]
Perl » comp.lang.perl.modules » Return keys from $db->DataHash directly into an array

Vorheriges Thema: $db->DataHash does not return keys/fields in same order as they appear in database
Nächstes Thema: Help with Math::GMP compile on AIX 5.3