Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Creating dispatch table with variable in function name

by Mr. Muskrat (Canon)
on Nov 21, 2017 at 19:41 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1203942]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-19 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found