[$index] -> [$index_of{Strand}]
[$index+1] -> [$index_of{Type}]
[$index+2] -> [$index_of{Pos}]
####
@index_of{@headers} = 0 .. $#headers;
####
#!/usr/bin/env perl -l
use strict;
use warnings;
my @test_headers = (
[qw{Strand Type Pos Length Form Adjustment}],
[qw{ID Strand Type Pos Length Form Adjustment}],
[qw{Strand XXX Type Pos Length Form Adjustment}],
[qw{Pos Type Length Strand Form Adjustment}],
);
for (@test_headers) {
my @headers = @$_;
my %index_of;
@index_of{@headers} = 0 .. $#headers;
print "Headers: @headers";
print "Strand index: $index_of{Strand}";
print "Type index: $index_of{Type}";
print "Pos index: $index_of{Pos}";
}
####
Headers: Strand Type Pos Length Form Adjustment
Strand index: 0
Type index: 1
Pos index: 2
Headers: ID Strand Type Pos Length Form Adjustment
Strand index: 1
Type index: 2
Pos index: 3
Headers: Strand XXX Type Pos Length Form Adjustment
Strand index: 0
Type index: 2
Pos index: 3
Headers: Pos Type Length Strand Form Adjustment
Strand index: 3
Type index: 1
Pos index: 0