Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: Invoking a string reference to a anonymous subroutine

by Superfox il Volpone (Sexton)
on Jan 15, 2014 at 12:48 UTC ( [id://1070679]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Invoking a string reference to a anonymous subroutine
in thread Invoking a string reference to a anonymous subroutine

Hi Rolf,

thanks for your reply.

But maybe you should care to define _handler within the scope of your private $_parse... variables to have a proper closure?
I believe you are right. I have come up with the following code:
my $_parse_handler = sub { my $self = shift; my $function = shift . '0'; # installed handlers my $_parse_element_configuration0 = $_parse_element_configuration; my $_parse_element_machines0 = $_parse_element_machines; eval "\$$function"; }; [...] my $handler = $self->$_parse_handler("_parse_element_" . $element->nam +e() ); $self->$handler($element);
Anyway I am getting the impression I am trying to bend the language to something it was not designed to do.

Kind regards,
s.fox

Replies are listed 'Best First'.
Re^5: Invoking a string reference to a anonymous subroutine
by LanX (Saint) on Jan 15, 2014 at 13:26 UTC
    Ugh... :-|

    Look now this really doesn't make much sense anymore.

    I was under the impression that you also need to call the handlers manually as private methods??? (they are now restricted to the sub)

    If not _please_ use dispatch tables!

    Cheers Rolf

    ( addicted to the Perl Programming Language)

    update

    older discussions covering dispatch tables (google ranked)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1070679]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-09-18 14:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (25 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.