I smell something bad here?
if ($col == 24) {
$buffer{'Y'} = trim($val);
return;
}
if ($col == 25) {
$buffer{'Z'} = trim($val);
return;
}
if ($col == 26) {
$buffer{'AA'} = trim($val);
return;
}
if ($col == 27) {
$buffer{'AB'} = trim($val);
return;
}
The names look suspicious, too. If you’re looping through the columns, try the magic ++ operator.
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:
(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!