Skip to content

Instantly share code, notes, and snippets.

@fiedsch
Last active August 29, 2015 14:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save fiedsch/44f8ccbbd2f72e9007fb to your computer and use it in GitHub Desktop.
# Mapping Excel Column Name ("A", ..., "Z") to Perl Arrayindex
sub EC {
my $name = shift;
if ($name !~ /^[A-Z]+$/i) {
die "ungültiger Spaltenname $name\n";
}
# mehrstellige Spaltennamen rekursiv lösen
if ($name =~ /^([A-Z])([A-Z]+)$/i) {
return 26**length($2) * (EC($1)+1) + EC($2);
}
return ord(uc $name) - 64 - 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment