I am writing a program and I need to take the input of coordinates in a a10 format (lower case, no ":") and change it into a string of A:10 since the module I was given only reads in that format. The code I have right now is:
$combined = uc($topLeftCoord); #uppercases the letter
@chars = (split //, $combined); #splits on every character
print "@chars\n"; #debugging print
if ($chars[2] == 0){ #if it is 10, do this
$combined = $chars[0] . ":" . $chars[1] . $chars[2];
}
else{ #if it is any other number between 1 and 9, do this
$combined = $chars[0] . ":" . $chars[1];
}
It properly separates them, but I get an uninitialized error when there there is something like a3. How would I optimize this code? Any help is appreciated, thanks!
$combined = uc($topLeftCoord); #uppercases the letter
@chars = (split //, $combined); #splits on every character
print "@chars\n"; #debugging print
if ($chars[2] == 0){ #if it is 10, do this
$combined = $chars[0] . ":" . $chars[1] . $chars[2];
}
else{ #if it is any other number between 1 and 9, do this
$combined = $chars[0] . ":" . $chars[1];
}
It properly separates them, but I get an uninitialized error when there there is something like a3. How would I optimize this code? Any help is appreciated, thanks!