in reply to subroutine ref while "strict refs"

my %checkers = map {; no strict 'refs'; $_ => \&$_ } qw( check_char check_time check_date check_numeric );
or
my %checkers = map { $_ => \&$_ } # \&$_ is except from strict refs. qw( check_char check_time check_date check_numeric );
Then in the loop,
my $checker_name = $rec_layout_hash{$fields[0]}{$i}{"sub_routine"}; my $checker = $checkers{$checker_name} or die("Unrecognized checker $checker_name\n"); $checker->($value1, $value2);

Replies are listed 'Best First'.
Re^2: subroutine ref while "strict refs"
by Anonymous Monk on Jul 28, 2014 at 20:22 UTC
    \&$_ is except from strict refs

    Very good point, although I think (?) that's just a specific case of the more general exemption my $x = "foo"; my $y = \&$x; &$y; or my $y = \&{"foo"}; &$y;

      I didn't mean to be exclusionary. \&{EXPR} as a whole is exempt, including the \&$NAME shorthand. CONST->() is also exempt.

      For example, (\&$name)->() is the same as $name->(), but it bypasses the symbolic reference check requested by using strict.

Re^2: subroutine ref while "strict refs"
by viffer (Beadle) on Jul 29, 2014 at 03:32 UTC
    Thanks to everyone for your input, a number of options to consider. Much appreciated.