w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Adding a hash to array in perl, adds the same hash multiple times

You are adding a reference to the same %temp hash each time.

Change your code to say:

my %temp = ('key' => $_, 'value' => $hash{$_});

and each time through the loop %temp will be a different hash.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.