my $header_row= 'one two three four five'; ... my %name2Index; ... my $col=0; foreach my $col_head (split ' ',$header_row) { $name2Index{$col_head} = $col++; }
Or more simply as:
my @header_row = qw/ one two three four five /; ... my %name2Index; ... @name2Index{ @header_row } = 0 .. $#header_row;
In reply to Re^4: making presence/absence table from a hash of arrays
by jwkrahn
in thread making presence/absence table from a hash of arrays
by reubs85
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |