Hi,

Sharan Basappa <sharan.basa...@gmail.com> asked:
> I am reusing a code for some enhancements. According to my
> understanding, it is a record with
> some unique string as key and then hash array as the value.
> 
> I iterate through the array and print as follows:
> 
> foreach my $key (keys %{$abc})
> {
>   print "$key ${$abc}{$key} \n";
> }
> 
> I get values such like:
> val_0001 HASH(0x186c0060)
> val_0002 HASH(0x187ea490)
> val_0003 HASH(0x18655bc0)
> val_0004 HASH(0x1880fc60)
> 
> Can someone tell me how to get the actual value instead of HASH* as
> above?

Assuming that $abc is a hash reference, it works like this:

#!/usr/bin/perl -w

use strict;

# $abc is a hash reference
my $abc = {
  'foo' => 1,
  'baz' => 2,
  'bar' => 3,
};


foreach my $key (keys %$abc)
{
  print "$key $abc->{$key}\n";
}

__END__

HTH,
Thomas

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to