In Apache2::Request you need to use a Perl closure to pass the hook_data. There's a great explanation on what a Perl closure is at http://www.perl.com/pub/a/2002/05/29/closure.html, but I'd look at working sample code before reading it (and then again after). The general idea is we make a "private" version of the hook subroutine that already contains the private data. As an example, you could glance at http://search.cpan.org/src/ISAAC/Apache-UploadMeter-0.9915/lib/Apache/UploadMeter.pm In this example, theres a special sub called hook_handler which takes the external hook_data and just returns a reference to an anonymous subroutine which is the actual handler. The reference doesn't go out of scope when it's returned, and since it's still in scope, so is the $hook_data variable (this would be a good time to read the above article).

Hope this helps clarify a bit,
 Issac

Michael Michalowski Web.de wrote:
hi,

 I need to ask another question concerning Apache2::Request and the
 upload hook. Documentation says, that it's possible to pass custom
 data to the upload hook via HOOK_DATA parameter. Actually I noticed,
 that this feature seems to be disabled in Apache2::Request:

 Request.pm: sub hook_data {die "hook_data not implemented"}

 Every example I found at google was written for Apache::Request (not
 Apache2::Request) and so I'm a bit confused how to pass data to my
 upload kook. It seems that the only data passed to the upload
 callback is a APR::Request::Param object and the filedata from the
 buffer. I tried to find a way to get the Apache2::Request Object or
 Apache2::RequestRec Object with the APR::Request::Param object, but
 there's no backwards reference (I wanted to store data with
 $r->notes() method).

 Can you please explain to me, how communication with the upload hook
 is possible using Apache2::Request?

 Thanks in advice!

best regards,
Michael

Reply via email to