I have a function which accepts an input from the user. The input maybe an integer, a float or a string. I have three overloaded functions which should be called based on the DATA TYPE of the entered data. For example, if the user enters an integer (say 100), the function having integer parameter should be called. If the user enters a string (say “100”) the function having the string parameter should be called.
So I need to find out the data type of the entered data. With regular expressions I am able to distinguish between an integer and a float (since I just need to find out the type, I wont prefer using the library provided at cpan.org), but I am not able to figure out how to differentiate an integer from a string. Perl treats “100” and 100 as the same? Is there any way to work around this problem?
From
perldoc perldata:So for integer scalars, you’ll just need to decide ahead of time how you want to process them. Perl will cheerfully convert from a number to a string or vice versa depending on the context.