use strict; use warnings; #Using a hash table #Evaluate on the first digit of the string { my ($var2) = @_; # $var1 = shift; # is slightly faster with one var # my ($var1, $var2) = @_; # slightly faster than than 2 shifts # normally this minor difference doesn't matter. # Perl can implement the if/else idea very code efficiently. return ("One") if ($var2 =~ /^1/ ); return ("Two") if ($var2 == /^2/ ); return ("Three") if ($var2 == /^3/ ); return undef; } # I want to evaluate the number 1.00.000 # I thought I would just have to pass it # to the subroutine to get a return value. test2(1.00.000);