If I have the following array
my @header_line = ('id', 'name', 'age');
How to create a hash from the equivalent of the line below?
my %fields = { id => 0, name => 1, age => 2};
The reason I want to do this is because I can use meaningful names, not magic numbers for indexes. For instance:
$row->[$fields{age}];
source
share