Click here to get back home

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

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Return keys from $db->DataHash directly into an array dtshedd 09-16-2007
Posted by dtshedd on September 16, 2007, 11:56 am
Please log in for more thread options


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) {
        @fields[$i]=$key;
print "my field $fields[$i]\n";
$i++;

}


TIA

dan


Posted by Mike Pomraning on September 16, 2007, 4:37 pm
Please log in for more thread options


dtshedd@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) {
>         @fields[$i]=$key;

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

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

Regards,
Mike

Similar ThreadsPosted
$db->DataHash does not return keys/fields in same order as they appear in database September 16, 2007, 11:59 am
Zertifikate/Keys September 17, 2007, 4:16 am
system return value? January 26, 2007, 5:52 pm
perl : Importing registry keys February 3, 2005, 11:34 am
Net::Cmd::code doesn't return value of Net::Cmd::dataend January 10, 2005, 9:17 pm
Curses::UI::Widget - binding function keys July 18, 2006, 1:53 am
Parsing return message from fetchmail June 27, 2006, 3:04 pm
SSH Modules: Accessing CLI box using SSH and not getting the return output?? November 12, 2006, 11:48 pm
Will XML::Simple work with keys, strings, integers, and dates? March 21, 2005, 10:43 am
Net::SSH::W32Perl Script hanging when trying to return data March 10, 2005, 1:14 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap