Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Creating dispatch table with variable in function name

by Mr. Muskrat (Canon)
on Nov 21, 2017 at 19:41 UTC ( #1203942=note: print w/replies, xml ) Need Help??


in reply to Creating dispatch table with variable in function name

It works for me.
#!/bin/env perl use strict; use warnings; my %dispatch = map { $_, \&{'_create_' . $_} } qw(first last); sub _create_first { print "first!\n"; } sub _create_last { print "last!\n"; } $dispatch{first}->(); $dispatch{last}->(); __DATA__ first! last!

Update: Do you have a subroutine called _create_create_password?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2018-10-18 18:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...














    Results (103 votes). Check out past polls.

    Notices?