First, there is no way to effectively pass compiled code between processes at this time. It isn't likely to happen with Perl 5 because attempts at loading compiled bytecode from disk have usually had poor performance and other issues.
Second, what you're proposing is probably not a good idea unless this is for a small in-house project. > What I mean is, if a request comes in for a certain form I would like to be > able to do something like this: > > my $form = &load_form($r); > $c{$session_id}->{handler} = $form->{handler}; # <-- this being a code > ref... > $r->send_http_header; > print $form; > > Then when the user completes the form and resubmits: > > my $handler = $c{$session_id}->{handler}; > $r->send_http_header; > print $handler->($r); What if the same user has multiple browser windows open and starts on a new form before finishing the existing form? Remember, sessions are global to all browser windows. The right thing to do here is pass the form data the old-hasioned way, in URLs or form fields. Those are distinct for each browser window. > I would like to be able to dynamically create anonymous > subroutine handlers based on input and have them be active until the form is > submitted, at which time they are used to process the form then discarded. But why go to all that trouble, generating subroutines on the fly? It just doesn't seem necessary for processing form input. - Perrin