in reply to text-file parsing with automatic field ordering

Is this type of referencing okay or insane, or is there mayber a simpler/better/faster way?

With some minor corrections and a pair of things I would do differently, it seems fine to me.

Update: here's one possible way I'd do it (note in particular that I don't use %index):

#!/usr/bin/perl use strict; use warnings; chomp (my $headerline = <DATA>); $headerline =~ s/^#// or die "Not a correct headerline"; my @keys=split /:/, $headerline; my @array; while (<DATA>) { chomp; my %hash; @hash{@keys}=split /:/; push @array, \%hash; } # examples print "1st name : $array[0]{'name'}\n"; print "3rd category : $array[2]{'category'}\n"; # traverse entire array for my $idx (0..$#array) { my $row=$idx+1; print "Row $row: ", (map "$_=$array[$idx]{$_} ", @keys), "\n"; } __DATA__ #name:surname:category tiger:woods:golfer tyler:hamilton:f1 james:stewart:supercross roger:federer:tennis

It seems simpler to me.