#!/usr/bin/perl use strict; use warnings; use constant {CC0 => 0, CC1 =>1}; # just some "gravy" # CC0 means 0 and CC1 means 1 use Data::Dump qw(pp dd); my @input_array = qw(N1 N2 N3 N6 N7 B3 B4); #not fixed (user input) my %hash; foreach my $inputKey (@input_array) { @{$hash{$inputKey}} = (1,"xyz"); # each key of the hash has an # array with 2 members } #### set N3, CC0 to "hey" ##### my @array = @{$hash{"N3"}}; # read array for hash key of N3 $array[CC0] = "hey"; # modify array @{$hash{"N3"}} = @array; # write modified array back ## update.. ## yes, @{$hash{"N3"}}[CC0] = "hey"; ## will do the same thing, but I wanted to show simple steps pp \%hash; __END__ { B3 => [1, "xyz"], B4 => [1, "xyz"], N1 => [1, "xyz"], N2 => [1, "xyz"], N3 => ["hey", "xyz"], N6 => [1, "xyz"], N7 => [1, "xyz"], }