Worksheet, where the first line contains these headers:
KEY | GLO | LOC | CPC | GROUP |
We have a table, representing the mapping between words from the worksheet and other words.
word 1 | word 2 |
---|---|
KEY | word |
GLO | global_monthly_search |
LOC | local_monthly_search |
CPC | CPC |
GROUP | group |
Array, containing the mapped words in the order, corresponding to the order of the original names:
word | global_monthly_search | local_monthly_search | CPC | group |
If the order of names in the input row changes, order of the columns in the result array must change correspondingly.
sub parse_header # {{{ { my $worksheet = shift; my %values = ( "KEY" => "word", "GLO" => "global_monthly_search", "LOC" => "local_monthly_search", "CPC" => "CPC", "GROUP" => "group", ); my $n = keys(%values); my @result; for (my $i = 0; $i < $n; $i++) { if(defined($values{$worksheet->{Cells}[0][$i]->value})) { push(@result, $values{$worksheet->{Cells}[0][$i]->value}); } } return \@result; } # }}}