On Wed, 19 Jan 2000, Jonas Nordström wrote:

> I had the same problem. What does the "1" mean? That the sub returns with a
> true value?

yes, from ch9:

=item do()

This method provides a way to iterate through an entire table item by
item.  Pass it a reference to a code subroutine to be called once for
each table entry.  The subroutine should accept two arguments
corresponding to the key and value respectively, and should return a
true value.  The routine can return a false value to terminate the
iteration prematurely.

This example dumps the contents of the I<headers_in> field to the
browser:

  $r->headers_in->do(sub {
                         my($key, $value) = @_;
                         $r->print("$key => $value\n");
                         1;
                      });

For another example of I<do()>, see listing 7.12 from the previous
chapter, where we use it to transfer the incoming headers from
the incoming Apache request to an outgoing LWP I<HTTP::Request>
object.

---

which means, ch7's example is broken, or that $request->header returned a
true value when the example was written.  I suppose the ch7 example should
explictly return 1 regardless.

Reply via email to