The names look suspicious, too. If you're looping through the columns, try the magic ++ operator.
my $colname = 'A';
for (0..$#cols)
{
# do stuff with $colname
$buffer{$colname} = trim($val);
++$colname;
}
If not, there does seem to be a pattern here that you can exploit for converting numbers from decimal (digital) to alphabetic. You'd do it the same way you'd convert a digital number to decimal, except that you'd use characters A-Z, base 26, instead of 0-9, base 10. Something like:
sub colname
{
my $num = shift;
my $name = '';
while ($num)
{
$name .= chr(ord('A') + $num % 26);
$num /= 26;
}
reverse $name;
}
(untested) This algorithm is language-neutral. It doesn't particularly take advantage of perlishness, but works wonderfully as a general-case.
Update: I told you this was untested. j_random_hacker pointed out the thinko, and I've corrected it. Thanks!