in reply to use strict refs unless you can't figure out the syntax
Looks like you may be trying to dispatch to a selected sub by storing the name of the sub in a hash. If you store a reference to the sub instead the intent becomes clearer, to need for the string ref is removed, maintenance becomes easier and the code is better checked for typos. Consider (sample code only - unchecked):
my %request_hash = ( my $returned_hash_ref = Logic => \&request_logic::nnnnn, ); #... if ($request_hash{Logic}) { $request_hash{Logic}->($request_hash_ref, $log_file); } else { #...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: use strict refs unless you can't figure out the syntax
by AnomalousMonk (Archbishop) on Jan 07, 2010 at 17:01 UTC | |
by theleftsock (Beadle) on Jan 08, 2010 at 05:01 UTC | |
by GrandFather (Saint) on Jan 08, 2010 at 08:28 UTC | |
by GrandFather (Saint) on Jan 08, 2010 at 07:58 UTC |