I have two arrays @arr1 and @arr2 and I have a hash %hash in my Perl code.
I have certain elements in @arr1 and similarly certain elements in @arr2. I want to push elements of @arr1 as key for hash %hash and elements of the array @arr2 as values for those keys for hash %hash.
I am using the below code in my Perl script to do so:
use strict;
use warnings;
use Data::Dumper;
my %hash = ();
my @abc = ('1234', '2345', '3456', '4567');
my @xyz = ('1234.txt', '2345.txt', '3456.txt', '4567.txt');
push(@{$hash{@abc}}, @xyz);
print Dumper(%hash);
After executing, I am getting the below output:
./test.pl
$VAR1 = '4';
$VAR2 = [
'1234.txt',
'2345.txt',
'3456.txt',
'4567.txt'
];
It is not printing the key values but their total number. I need the output to be that every key with its value gets printed after I execute the script.
Can someone please help. Thanks.