[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    [off] giving call-back-func parameters...
From:       "raptor" <raptor () unacs ! bg>
Date:       2001-07-31 16:52:13
[Download RAW message or body]

hi,

sorry if this is a litle bit off-topic, but doesn't know where to post it...
Of all 10 mailing lists and 11 newsgroups this seems to be most suitable
:")... so here is it :

I have the following situation :

A main module BigOne.pm a Helper.pm(here i have required function
implemented), so in the script I have something like this :

script.pl
===========
use Helper;
my $callbackFunc = \&Helper::func;
my $obj = new BigOne ( vals => $callbackFunc);

BigOne.pm
==========
my $vals = shift;
....
if (ref $vals eq 'CODE') {
   ...........
    my $kv = &$vals( id => $selected, dbh => $$self{dbh} );
   ..............
};
....

See  $kv gets the return value from Helper::func(),  everything is OK until
I need to pass one more parameter to this function which I don't know in
BigOne.pm but know at script.pl.... i.e. I want to say something like this :

my $callbackFunc = \&Helper::func( additional_parameter => 'xxx'  );

and then the real call (in BigOne) has to become :

my $kv = &$vals( id => $selected, dbh => $$self{dbh}, additional_parameter
=> 'xxx'  );
instead of just :
my $kv = &$vals( id => $selected, dbh => $$self{dbh});


Any help very appricated....

PS. One possible solution is to pass one or more parameters at the creation
of BigOne object but this is not acceptable in my case.. 'cause it is a
little bit more complicated ..
One last-resort solution is to create a function in script.pl which will get
the parameters from &$vals()-call and then redispach/recall Helper::func()
on its behalf!... i.e. behave like proxy
( BigOne-&vals --script.pl-->Helper::func() )  .. is there better way !?
'cause if I use this way I have to also take care for return values which
can be a ref-ARRAY but also can be flattened array with alot of elements :"(
Thanx again and sorry for loosing your time !!
=====
iVAN
raptor@unacs.bg
=====

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic