Hello community I hope I can meet some byte string experts here. I guess SvPVbyte comes into play, but how?
My problem. I already sucessfully parse Perl array XYZ (within a hash of arrays) with example index 6789) within Inline:C with Perl:
$testn=pnp($lengthofXYZ,\@{$XYZ{$_}});
Inline C:
int pnp ( int n, SV *vertx)
AV *arrayx;
double val_of_interest;
arrayx = (AV *)SvRV( vertx );
SV **yi;
yi = av_fetch( arrayx, 6789, 0 );
val_of_interest = SvNV( *yi );
return calculation_with_val_of_interest
This works perfectly. But lets say I have a very long byte string (about 10-50MB) in Perl $xyz="\x09\x07\x44\xaa......
Now I want to pass a reference to this SV and walk in 9 byte steps (substr like) in C part throu this string without copying it completely in an own C array for example.
The walking part: first 4 bytes shall be checked against a reference 4 Byte value ABC that also shall be in the function call. If necessary I can unpack "N" this search phrase before and call function with integer. If postition 0 not successfull jump/increment 9 bytes furter, if sucessfull I will deliver the found position as return.
Thank you so much.
[This is an answer to the question in the comments]
use bytes;
. "Use of this module for anything other than debugging purposes is strongly discouraged." (And it's not actually useful for debugging purposes. Devel::Peek is more useful.)our
here.int
could be too small for the return value.Of course, you could simply use