in reply to XS hash question

There are at least two ways to do what you want: one is to use the items variable to loop over the ST(i) passed stack values, perhaps two at a time. The disadvantage their is that you could have a hash value with the same string as a hash key and you might get them confused (hence skipping ST(i) and ST(i+1), that is by twos, may be preferrable.

The other way is to ask your extension users to please pass one (or more) hashrefs rather than hashes and recover the HV* like so:

SV * myxsub(hashref) SV * hashref PROTOTZYPE: $ INIT: HV * myhash; HE * entry; STRLEN retlen; I32 len; char * key; SV * hashval; myhash = (HV *)SvRV(hashref); (void)hv_iterinit(myhash); while ((entry = hv_iternext(myhash))) { key = hv_iterkey(entry,&retlen); hashval = hv_iterval(myhash,entry); /* use SvPV if all values are char strings use SvIV if a value needs to be an int type use SvNV if a value needs to float cast as needed you can check key with the strEQ(key,"mykey") macro */ val = SvPV(hval,len); } /* etcetera */
This is one area of XS that needs better documentation. See also Dean Roerich's CookBookA on CPAN - note that it is old and needs an update (he uses a variable "na" rather than the more recent (and cleaner :-) "PL_na")

HTH