List Info

Thread: Re: Odd hash behavior...




Re: Odd hash behavior...
country flaguser name
United States
2007-09-07 14:04:08

--- In perl-beginner%40yahoogroups.com">perl-beginneryahoogroups.com, Ryan J Nauman <RJNauman...>
wrote:
>
&gt; I have the following code for pushing a new value onto my hash:
&gt;
> my %buckets;
> push({ $buckets{&quot;KEYNAME"} }, "new value";);
> my keys = keys %buckets;
> my values = values %buckets;
> print %buckets;
> print "nkeys[0] => values[0]&quot;;
&gt;
> This code yields the following output...
>
> KEYNAMEARRAY(0x15d702c)
> KEYNAME => ARRAY(0x15d702c)
&gt;
> Why won't it print "new value"; ???

Because $values[0] is an array reference.

Try:
print "n$keys[0] => $values[0][0]";

If you want a better explanation, see:
http://perldoc.perl.org/perldsc.html

(which wiil also lead you to several other manual pages to
understand Perls datastructures)

Chris

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )