in reply to detecting of scalar is string or numeric
Now, you might be able to find a variable for which foo() and xor_check() return different values.use strict; use warnings; use Inline C => Config => BUILD_NOISY => 1, ; use Inline C => <<'END_C'; int foo(SV * in) { if(SvIOK(in) || SvNOK(in)) return 1; return 0; } END_C my $num = 42; my $str = "42"; my $ref = \$num; my $nv = 42.42; my $dual = "42"; # POK flag set. if($dual > 0){} # IOK flag also set print foo($num), " ", xor_check($num), "\n"; print foo($str), " ", xor_check($str), "\n"; print foo($ref), " ", xor_check($ref), "\n"; print foo($nv) , " ", xor_check($nv) , "\n"; print foo($dual), " ", xor_check($dual), "\n"; sub xor_check { return 0 if($_[0] ^ $_[0]); return 1; } __END__ Outputs (perl-5.24.0): 1 1 0 0 0 0 1 1 1 1
|
|---|