in reply to Sub Routine Problem

if ($card_map[$num]) { $card_map[$num]; # return value } else { $num; # return value } # end if

Here is (one of your) problem(s).

$num will only be returned if you either write return $num, or if it's the last statement in your sub, which it isn't.

Also note that $card_map[$num] will return something for negative values of $num, (in that case it counts the index from the back of the array):

$ perl -wle 'my @card_map = qw(zero one two three); print $card_map[-2 +]' two

So you most likely need something like this:

my $return_value = ''; if ($num < 0) { $return_value = $negative; # continue with the positive value from here on $num = -$num; } # and append other results here: $return_value .= $card_map[$num]; return $return_value;

(I'm also quite sure that you should forget about local for now, and work with my).