hi,
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_param
+eter => '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 !!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.