in reply to Handling both string and numeric comparisons
I have to agree with holli. Can you show a piece of code where ( $param eq '5' ) fails? Perl will convert integers to string automatically. The only time I have problems is when I need to force an integer.
perl_devel writes:
"is there a way to check if $param is integer of string and based on that do a string or integer comparison?"I don't see the purpose. Perl does the integer to string conversion automatically depending on what it thinks it needs. To check for both would require explicitly casting a string to an integer. So, if you are casting it to one or the other, what's the point??
|
|---|