<?xml version="1.0" encoding="windows-1252"?>
<node id="1011162" title="Re^3: My CPAN Resolutions (perlcritic)" created="2013-01-01 11:35:39" updated="2013-01-01 11:35:39">
<type id="11">
note</type>
<author id="757127">
tobyink</author>
<data>
<field name="doctext">
&lt;p&gt;Stringy eval has its uses. [mod://Moose] and [mod://Moo] use it extensively for creating fast inlined accessors and constructors. [mod://Template|Template-Toolkit] uses it to create templates.&lt;/p&gt;
&lt;p&gt;However it can also enable all sorts of ugly practices. For example, poor man's symbolic references...&lt;/p&gt;
&lt;c&gt;
use strict;

my $red    = '#ff0000';
my $green  = '#00ff00';
my $blue   = '#0000ff';

my $colour = 'green';
my $hex    = eval "\$$colour"; # symbolic reference
print "$hex\n";
&lt;/c&gt;
&lt;p&gt;When many newcomers turn to stringy eval, it's often because they're unaware of a better solution to their problem.&lt;/p&gt;
&lt;p&gt;This is my problem with [mod://Perl::Critic]. It takes a generally good guideline (stringy eval is often a bad idea; investigate other options first) and turns it into a concrete rule.&lt;/p&gt;
&lt;p&gt;Yes, of course there's &lt;c&gt;no critic&lt;/c&gt; comments but I don't really want to litter those around my code like rat droppings. (&lt;c&gt;no strict&lt;/c&gt; and &lt;c&gt;no warnings&lt;/c&gt; are already enough of an eyesore.)&lt;/p&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-757127"&gt;
&lt;small&gt;&lt;small&gt;
&lt;tt&gt;perl -E'sub Monkey::do{say$_,for@_,do{($monkey=&amp;#x5B;caller(0)]-&gt;&amp;#x5B;3])=~s{::}{ }and$monkey}}"Monkey say"-&gt;Monkey::do'
&lt;/tt&gt;&lt;/small&gt;&lt;/small&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1011110</field>
<field name="parent_node">
1011157</field>
</data>
</node>
