Sounds plausible, except that the crc and length are computed based on the 
uncomressed copy of the original text (in $state_ref->{'body'}), which is 
unchanged by the flush.


On Saturday 27 August 2005 01:18 pm, Malcolm J Harwood wrote:
> 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.

Reply via email to