Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Request for Perl::Critic Testimonials (some weirdnesses of the module)

by Herkum (Parson)
on Jul 15, 2006 at 20:14 UTC ( #561479=note: print w/ replies, xml ) Need Help??


in reply to Re: Request for Perl::Critic Testimonials (some weirdnesses of the module)
in thread Request for Perl::Critic Testimonials

next if /^;/; #skip comments
It is complaining the xm switches are not included Change it to this,

Update: Also wrong per Jeronim

next if /^;/xms;
local $" = '|';
Don't use local variables, use my. Don't the special variables like $", use the English module.

Updated: Suggested but not working code

use English qw( -no_match_vars ); my $LIST_SEPERATOR = q{|};

Wrong spelling and yes will break your Code, Both pointed out by Jeronim and Chromatic...

use English qw( -no_match_vars ); { local $LIST_SEPARATOR = q{|}; }

Would love to delete the post for just being wrong... Oh well :)


Comment on Re^2: Request for Perl::Critic Testimonials (some weirdnesses of the module)
Select or Download Code
Re^3: Request for Perl::Critic Testimonials (some weirdnesses of the module)
by chromatic (Archbishop) on Jul 15, 2006 at 20:59 UTC
    This will get you through the critic...

    ... and break your code.

    use Test::More tests => 1; use English '-no_match_vars'; my $LIST_SEPARATOR = '|'; my @items = qw( foo bar baz ); my $interpolated = "@items"; is( $interpolated, 'foo|bar|baz', 'somehow package globals and lexical +s merged' );
Re^3: Request for Perl::Critic Testimonials (some weirdnesses of the module)
by Ieronim (Friar) on Jul 15, 2006 at 21:01 UTC
    You decided that my English is so poor that i can't read the docs of Perl::Critic and understand why these warnings appeared? ;)

    Your comment contains many errors :( Yes, if i modify my code according to your recommendations, Perl::Critic will stop complainingóbut my code will stop working :)

    Your recommendation to use

    next if /^;/xms;
    is very weird. The using of /s and /m switches together causes a very unexpected interpretation of the RegEx:

    perlretut says:
    both s and m modifiers (//sm): Treat string as a single long line, but detect multiple lines. '.' matches any character, even "\n". ^ and $, however, are able to match at the start or end of any line within the string.

    Do you still think that it's a good idea to add /ms to the end of each regex?

    Don't use local variables, use my. Don't the special variables like $", use the English module.
    use English qw( -no_match_vars ); my $LIST_SEPERATOR = q{|};

    1. The Perl built-in variables lose their magic capabilities when declared as my. Didn't you know?
    2. There is no $LIST_SEPERATOR. Use $LIST_SEPARATOR instead.
    3. If you don't believe me, try the following code:
      #!/usr/bin/perl use warnings; use strict; use English qw( -no_match_vars ); { local $LIST_SEPARATOR = q{!}; my @list = qw/this is my list/; print "@list\n"; }
      and then try to replace 'local' with 'my'.
      BTW, Perl::Critic does not complain about local'ising in the code above ;)

          s;;Just-me-not-h-Ni-m-P-Ni-lm-I-ar-O-Ni;;tr?IerONim-?HAcker ?d;print

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2014-07-26 01:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls