--- In perl-beginner%40yahoogroups.com">perl-beginneryahoogroups.com, Ryan J Nauman <RJNauman...> wrote:
>
> I have the following code for pushing a new value onto my hash:
>
> my %buckets;
> push({ $buckets{"KEYNAME"} }, "new value");
> my keys = keys %buckets;
> my values = values %buckets;
> print %buckets;
> print "nkeys[0] => values[0]";
>
> This code yields the following output...
>
> KEYNAMEARRAY(0x15d702c)
> KEYNAME => ARRAY(0x15d702c)
>
> Why won't it print "new value" ???
>
> I'm running perl, v5.8.8 build 822 from ActiveState.
>
> [Non-text portions of this message have been removed]
>
With
use strict; use warnings;
you get the hint that you are not using Perl properly.
Scalar value keys[0] better written as $keys[0] at t.pl line 10.
Scalar value values[0] better written as $values[0] at t.pl line 10.
my %bucket = (
KEYNAME => 'new value', ANOTHER => 'another value', );
foreach my $key (keys %bucket) {
print "key = $key, value = $bucket{$key}n";
}
for more information -> web search "perl hash howto"