Bernhard,
unfortunately, there is no easy way for attacking the problem directly. When 
SEC substitutes variables with their values in 'action' or 'action2' fields, it 
substitutes them as strings. Currently, there is no special treatment for 
references (and it would be a bit awkward to come up with a right processing 
scheme for them, since a variable could appear in the middle of string).
However, there is a simple workaround for the problem - you can assign the 
function pointer not only to the %-variable, but a Perl variable inside the 
main::SEC namespace as well. Instead of calling the function through a 
%-variable, you can employ the previously created Perl variable for this, which 
is a much cleaner and readable approach IMHO.
hth,
risto

> From: Bernhard Aichinger <[EMAIL PROTECTED]>
> Subject: [Simple-evcorr-users] Calling coderef from within eval
> To: [email protected]
> Date: Friday, July 18, 2008, 6:51 AM
> Hi,
> 
> 
> I would like to call a code reference stored within an
> %<alnum_name> 
> variable from within an eval action.  The demo code looks
> like this:
> 
> type=single
> ptype=substr
> pattern=SEC_STARTUP
> desc=$0
> action=eval %funcptr ( sub { return 1; } ); \
>         eval %err ( return &{%funcptr}; )
> 
> %funcptr works perfectly fine if called by a call action. 
> But
> calling from within an eval action fails.  It gives
> "Undefined subroutine
> &main::SEC::CODE":
> 
> Evaluating code 'sub { return 1; } ' and setting
> variable '%funcptr'
> Variable '%funcptr' set to 'CODE(0xbc1bb0)'
> Evaluating code 'return &{CODE(0xbc1bb0)}; '
> and setting variable '%err'
> Error evaluating code 'return &{CODE(0xbc1bb0)};
> ': Undefined subroutine &main::SEC::CODE called at
> (eval 8) line 1.
> 
> I tried different things to no avail.  Is there a solution
> to this problem?
> 
> 
> - Bernhard
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move
> Developer's challenge
> Build the coolest Linux based applications with Moblin SDK
> & win great prizes
> Grand prize is a trip for two to an Open Source event
> anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Simple-evcorr-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users


      

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Simple-evcorr-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

Reply via email to