perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <>
Subject Re: [mp2] last call for $filter->read
Date Wed, 02 Jun 2004 06:06:00 GMT
Stas Bekman wrote:
> I think this is the last function in the read() family that needs 
> tweaking (currently most errors are silently ignored). I've changed the 
> API to be consistent with the rest of modperl 2.0 read functions, and 
> the only added inconvenience is that you need to add defined inside 
> while call. So instead of writing:
>     while ($filter->read(my $buffer, $wanted)) {
>         $filter->print($buffer);
>     }
> You will write:
>     while (defined(my $buffer = $filter->read($wanted))) {
>         $filter->print($buffer);
>     }
> The existing API is badly broken, since there is no way to break the 
> while loop in case of an error. It was working perfectly when there are 
> no errors.
> Errors are now checked internally and exceptions are thrown if anything 
> goes wrong.
> I've adjusted all the tests and they all pass fine. Let me know if you 
> have any problem with that change.

Or may be we should keep it as is and just fix the error handling.

     while ($filter->read(my $buffer, $wanted)) {

is still easier to write... and if you forget the defined() part you may get 
errors when you get "0" as a returned string (which luckily one of the tests 
has happened to do).

Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker     mod_perl Guide --->

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message