in reply to Distiguishing arguments: number-strings vs real integer

Another solution, which IMHO is a little more elegant than having to parse the output of another module: Scalar::Util's isdual() will return true for a scalar that has both a number and string representation. As documented, this is true for a number used in string context and the reverse for a string.

So a scalar is a number if it becomes dual after stringification, and is a string if it becomes dual after numification (and is a trap if already dual to begin with ;-) ).

perl -MScalar::Util=isdual -E "@v = (0, 1, 2, '3', '4', '5'); push @v, + @v; push @v, $v[0].$v[3]; push @v, $v[1]+$v[4]; isdual($_) and say f +or @v" 0 4
The push @v, @v is to check that a variable's copy is left unaffected by the stringification/numification of the original (yes it's a very weak and useless check :P). After that, I stringify $v[0] and numify $v[4]. (The values 2, and 5 are unused so not dual, 1 and 3 are used as number and string respectively, which they already were)