sub smstype { # Using uc() will allow the user to enter lowercase letters too my $first = uc($_[0]); my $sms; my $i = 0; foreach my $j ( split //, $first ) { $sms .= $telealph{$j}; # Make sure we get a comma between digits, but not at the end $sms .= ", " if (++$i < length($first)); } return $sms; }