> -----Original Message-----
> From: T. Murlidharan Nair [mailto:nair@;sdsc.edu]
> Sent: Thursday, November 14, 2002 2:22 PM
> To: [EMAIL PROTECTED]
> Subject: fetchrow_hashref
> 
> 
> Hi!!
> I am retriving data in a while loop using fetchrow_hashref
> How do I assign it to another hash.  I am trying the following
>  
>     while (my %hashRef =$sth->fetchrow_hashref()){

fetchrow_hasref returns a hash reference, which is a scalar.
You need to assign it to a scalar and dereference it.

Using -w would have generated a warning about this.

>         foreach $keys (keys %hashRef){
>                 print $keys;
>                 print "$hashRef{$keys}\t";
>         }
>     print "\n";
> }
> 
> Its  does not return me anything. Please let me know if there 
> is a  better
> way to handle it.

Try something like this:

   while (my $h = $sth->fetchrow_hashref) {
       for my $key (keys %$h) {
          print $key, '=', $h->{$key}, "\n";
       }
   }

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to