Hi everyone. I have a question about the Perl API.
I have a C function that manipulates an AV. Basically, it needs to push SV *'s containing unique strings into the AV, and then periodically remove an SV from the list. To remove an SV, I'd like to, um, grep it, kind of like this:
$scalar_to_remove = 'unique_string'; @array = grep({$_ ne $scalar_to_remove} @array);
How exactly can I accomplish this from C? Do I need to use perl_call_pv(sv_2mortal(newSVpvn("grep", 4))) and then do some stack magic to satisfy grep's calling conventions, then some more stack magic to copy back the resulting array? If so, is there any other simpler way to remove a scalar from an AV? A C equivalent of splice() maybe? I looked into av_delete(), but it's recent as of 5.6, which makes me suspect that it behaves just like delete() does when called on an array (undefs the scalar but doesn't remove it from the list; doesn't shrink the list).
Thanks in advance.
In reply to Removing an element from an AV? by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |