in reply to Subroutine references inside of a hash with arguments.
With
"1" => \&get_ifc_name,
the hash value is a reference to the subroutine get_ifc_name, but with
"1" => \&get_ifc_name({'ifc_default' => 'test_me',}),
the hash value is a reference to whatever that subroutine returns when called with the specified argument. Even if the subroutine returns a reference to a subroutine, it will be inconsistent with the previous case.
Maybe, instead of a single value for each element of the %menu_hash hash, you should have a reference to a hash, something like:
"1" => { sub => \&get_ifc_name, args => {'ifc_default' => 'test_me',} +},
Later, you can call this with
$menu_hash{1}{sub}->($menu_hash{1}{args});
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Subroutine references inside of a hash with arguments.
by ikegami (Patriarch) on Jul 25, 2009 at 04:56 UTC | |
by ig (Vicar) on Jul 26, 2009 at 01:36 UTC | |
by LanX (Saint) on Jul 26, 2009 at 12:31 UTC | |
by ig (Vicar) on Jul 26, 2009 at 20:48 UTC |