in reply to Symbolic reference with strict "refs"
What you're really asking is how to write dodgy code in a way that is obscured from strict's view; a way that either the makers of strict didn't think of, or thought of and figured if you're going to that much trouble you must have your reasons. Still dodgy, and maybe even more-so because it does its little dirty deed so quietly that a future maintainer won't have the benefit of the visual cue that no strict 'refs'; provides.
I would opt for the no strict 'refs'; ## no critic (strict) method in the narrowest possible scope.
By the way, there are plenty people who's opinions I respect who will tell you that the crime isn't in writing code that requires no strict 'refs';, but in writing such code unnecessarily and dangerously. Dodgy is when it's used to solve a problem created by poor design. Genius is when it falls into the category of "Making difficult things possible."
I wanted to mention an article that Mark Jason Dominus wrote. We're all familiar with his article that talks about why it's stupid to use a string as a variable name. But he has another gem that gets a little less attention. Here's the snippet that I find interesting.
A programmer posted to comp.lang.perl.misc with an example that manufactured a function name at run time, and then called the function. Many people jumped in to say this was a mistake, some even saying it was a mistake because it caused a strict 'refs' violation. This is nonsense. Violating strict 'refs' is like setting off the fire alarm. It is a warning that something dangerous may be occurring; it is not a problem in itself. The problem is the fire.
What is the fire, the real problem, in this case? I wrote a series of widely-read and often-cited articles about the problems that arise from using values as the names of variables and functions. Before responding to this thread, I read over the articles, checking each problem I mentioned to see if it could occur in the original programmer's code. None of the real problems could actually arise. I said that I was not able to see what the problem was, and asked people to explain it.
...
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Symbolic reference with strict "refs" (it stinks!)
by tye (Sage) on Aug 17, 2012 at 21:13 UTC | |
by chromatic (Archbishop) on Aug 17, 2012 at 21:50 UTC | |
|
Re^2: Symbolic reference with strict "refs"
by Anonymous Monk on Aug 17, 2012 at 19:36 UTC |