my @header_row = qw/ one two three four five /; ... my %name2Index; ... @name2Index{ @header_row } = 0 .. $#header_row;