NateTut has asked for the wisdom of the Perl Monks concerning the following question:
Update: Added -> to ref and fixed typo in title Update 2: To Clarify what I'm trying to do here is to call the sub reference stored in the Procedures hash with the argument $Parameter. This is a simplified case of my real world problem#!/usr/bin/perl use strict; use warnings; sub Procedure_Name_1 { my($Parm) = shift; print($Parm); } my %Procedures; $Procedures{'ProcName1'} = \&Procedure_Name_1; my $Procedure = 'ProcName1'; my $Parameter = 'Some Value'; &$Procedures->{$Procedure}($Parameter);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to call a sub ref from a hash
by almut (Canon) on Dec 15, 2008 at 22:51 UTC | |
|
Re: How to call a sub reff from a hash
by Joost (Canon) on Dec 15, 2008 at 21:59 UTC | |
by NateTut (Deacon) on Dec 15, 2008 at 22:06 UTC | |
by Fletch (Bishop) on Dec 15, 2008 at 22:10 UTC | |
by NateTut (Deacon) on Dec 15, 2008 at 22:12 UTC | |
by ikegami (Patriarch) on Dec 15, 2008 at 22:17 UTC | |
| |
by Fletch (Bishop) on Dec 15, 2008 at 22:16 UTC | |
| |
by Joost (Canon) on Dec 15, 2008 at 22:37 UTC | |
by eric256 (Parson) on Dec 15, 2008 at 22:52 UTC |