in reply to Re: Re: A little C code converted to Perl *HELP*
in thread A little C code converted to Perl *HELP*
cant get that line working you gave me .. always give me 0 , or 1 ...
Yes, of course. Should almost always be 0, I think. (rand with no arguments produces a number between 0 and 1; you're left-shifting that a whole bunch and then evaluating it in integer context.) The question is, what did you *want* it to do? If you can tell me what the C code *does*, we can save all this guesswork and get straight to a _working_ example. Even a really *vague* explanation in English would be preferable to C code. I tried reading the C code, but I had to make some assumptions about things I wasn't sure about, and since you're unhappy with my translation, it's apparent that some of my assumptions were wrong. In particular, I suspect I was wrong about what rand with no args does in C. If I needed to know that sort of thing, I'd be hanging out in comp.lang.c or someplace (or else committing ritual suicide).
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
|
|---|