[Chicago-talk] A Perl::Critic question

Jonathan Rockway jon-chicagotalk at jrock.us
Sun Apr 11 20:20:56 PDT 2010


* On Sun, Apr 11 2010, Elliot Shank wrote:
> On 4/10/10 10:10 PM, Steven Lembark wrote:
>> Maybe it just wants you to use intelligent braces:
>>
>>      sub foo
>>      { ## no critic
>>
>>      }
>
> That won't work: the location of the braces on a subroutine doesn't matter.  It's the location of the letter "s" in "sub" that matters.

How come you guys don't just walk the DOM?  Find the "no critic"
comment, and go backwards from there until you hit something interesting
("sub" in this case, "some random line of code" in other cases).

But anyway, clearly the solution for the current variant is to say:

    #line 42
    sub foo {
    #line 42
        ## no critic
        $your->code('goes here');
    }

Now they are on the same line ;)

Theoretically, you could even say:

   #line 42
   sub foo {
      this "is foo";
   }

   sub something_else {
   #line 42
       ## no critic
   }

and disable criticism for foo instead of something_else.

I guess there should be a perl critic rule to detect people abusing
#line to confuse perl critic.  But wait... :)

--
print just => another => perl => hacker => if $,=$"


More information about the Chicago-talk mailing list