So I'm trying to set up a subroutine to test input types to make sure they're the right sort (numeric, etc) I figure regex is the way to go, but it doesn't seem to work. The script:
#!perl print input_test('a', 'numeric'), "\n"; sub input_test { my ($input, $test_type, $output) = ($_[0], $_[1], $_[0]); if ($test_type eq 'numeric' and not $input =~ m/^\d*$/) { # numeric *and* non-decimal $ouptput = 'Non-numeric input'; } elsif ($test_type eq 'decimal' and not $input =~ m/^(\d|\.)*$/) { # doesn't test for multiple decimals $ouptput = 'Non-decimal input'; } else { $output = 'Bad &Numbers::input_test() input'; } return $output; } __END__ prints 'a', same thing if $test_type is 'decimal'. In fact the only thing that seems to work is if $test_type is wrong. I've tried rewriting the syntax a bit (embedded if loops, using \D instead of \d...) but it comes out the same. What's up? ~wren