in reply to Can I catch exceptions
Note that the regex used above checks for whole numbers; several more useful regexes for other number types are listed in perlfaq4, under the question "How do I determine whether a scalar is a number/whole/integer/float?"if( $num1 !~ /^\d+$/ ) { warn "First value is not a number"; } elsif ( $num2 !~ /^\d+$/ ) { warn "Second value is not a number"; } else { my $result = ( $num1 == $num2 ); }
|
|---|