In real (production) code, you should also verify that you in fact have the appropriate types (using SvROK(), SvIOK(), etc.) before treating them as such
Yes, SvROK(*aref) should be checked, but checking SvIOK(*res) is not required because SvIV coerces.
#!/usr/bin/perl use Inline C => <<'EOC'; void show(SV* index) { PerlIO_printf(PerlIO_stdout(), "%d\n", SvIOK(index)); PerlIO_printf(PerlIO_stdout(), "%d\n", SvIV(index)); } EOC show("123456");
0 123456
In reply to Re^4: simple XS
by ikegami
in thread simple XS
by spx2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |