my %column_num; my @column_lbls = qw( Id Name SSN Phone FAX ); # initialize a hash with an array index: @column_num{ @column_lbls } = 0 .. $#column_lbls; # to find the index of the item matching $col_name: my $index = $column_lbls{$col_name}; # to find the column numbers of several columns (e.g., a database query): my @cols = @column_lbls{ qw(Name Phone FAX) };