Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: subroutine ref while "strict refs"

by ikegami (Pope)
on Jul 28, 2014 at 19:43 UTC ( #1095412=note: print w/ replies, xml ) Need Help??


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);


Comment on Re: subroutine ref while "strict refs"
Select or Download Code
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 (Sexton) on Jul 29, 2014 at 03:32 UTC
    Thanks to everyone for your input, a number of options to consider. Much appreciated.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1095412]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (17)
As of 2015-07-31 15:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (279 votes), past polls