in reply to Re^2: Detecting if a scalar has a number or string
in thread Detecting if a scalar has a number or string
So, you want only those things that are either numeric scalars or which inherit from overload and can provide the numeric comparisons. That's a good definition of what you feel a number is.
To achieve that, you will probably want to do something along these lines:
use Scalar::Utils qw( blessed ); use DBI qw( looks_like_number ); use overload; sub my_is_number { my $x = shift; unless ( blessed( $x ) ) { return looks_like_number( $x ); } if ( overload::Method( $x, '<=>' ) ) { return !!1; } return; }
Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
|
|---|