On Friday 26 August 2005 06:25 pm, Alexander Charbonnet wrote:
> It apparently works after I played with the code for the final flush. I'm
> not sure why, though. There was only one change (below). Anybody see a
> significant difference?
> In any case, I'll take it, since it works now. :-)
>
>
> ------Original (broken) code------------
> $f->print(join '',
> $state_ref->{'handle'}->flush(),
> pack("V V",
> crc32($state_ref->{'body'}),
> length($state_ref->{'body'})),
> );
> -------------------------------------------
My guess is that the above evaluates the pack before the flush in order to
pass the results to join(), so it's sending out the wrong length/crc.
> ------Working code----------------------
> $final_output = $state_ref->{'handle'}->flush();
>
> $f->print(join '',
> $final_output,
> pack("V V",
> crc32($state_ref->{'body'}),
> length($state_ref->{'body'})),
> );
> ------------------------------------------
This forces the flush to be evaluated first.
--
Crowley [the demon] had been extremely impressed with the warranties
offered by the computer industry, and had in fact sent a bundle Below
to the department that drew up the Immortal Soul agreements, with a
yellow memo form attached just saying: "Learn, guys."
- Good Omens, Terry Pratchett & Neil Gaiman