Just a short note on Perl strict refs. I had to dynamically load a module and call a function in perl while using strict mode. Originally tried this way:
my $module_name = "Blah"; eval("require $module_name;"); if ($@) { die "Failed to load module: $@\n"; } else { my $func_name = $module_name . "::do_something"; &$func_name("some args"); }
But got a warning that I am not allowed to do this while in strict refs. To fix this, had to change the last block to
my $func_name = $module_name . "::do_something"; my $func_ref = \&$func_name; &$func_ref("some args");
And all went fine. One other alternative was to use the next setup:
my $func_name = $module_name . "::do_something"; { no strict refs; &$func_name("some args"); }
Which would cancel strict refs in a short scope. But I didn’t like it :)