On Sun, Feb 20, 2005 at 04:36:52PM -0500 [EMAIL PROTECTED] wrote: > I'm trying to push a HV on the stacks. I've tried with > "XPUSHs(hv_scalar(hv));" but I get weird stuff when I print it with > Data::Dumper ("$VAR1 = '1/8';")
'hv_scalar(hash)' is the XS equivalent to $scalar = %hash; so that explains why you got '1/8' (meaning: one of eight buckets in the hash are used; you can use this value to measure the amount of collisions in case you're interested). Returning a hash can happen in two ways. Either return a reference: XPUSHs(sv_2mortal(newSVrv((SV*)hv))); or by returning the hash as a list, which is more cumbersome and slower: char *key; SV *val; I32 len; hv_iterinit(hv); while (val = hv_iternextsv(hv, &key, &len)) { XPUSHs(sv_2mortal(newSVpvn(key, len))); XPUSHs(val); } The above might be a bit off as I've never used 'hv_iternextsv' before. Tassilo -- use bigint; $n=71423350343770280161397026330337371139054411854220053437565440; $m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);