Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
Perl::Critic::PolPerl:UsertContributed:PerlsDocumentationlessRegexModifiers(3)

NAME
       Perl::Critic::Policy::Bangs::ProhibitUselessRegexModifiers - Adding
       modifiers to a regular expression made up entirely of a variable
       created with qr() is usually not	doing what you expect.

AFFILIATION
       This Policy is part of the Perl::Critic::Bangs distribution.

DESCRIPTION
       In older	versions of perl, the modifiers	on regular expressions where
       incorrectly applied. This was fixed in 5.10, but	no warnings were
       emitted to warn the user	that they were probably	not getting the
       effects they are	looking	for.

       Correct:

	 my $regex = qr(abc)m;
	 if ( $string =~ /$regex/ ) {};

       Not what	you want:

	 my $regex = qr(abc);
	 if ( $string =~ /$regex/m ) {}; ## this triggers a violation of this policy.

       See the thread that starts at:
       <http://www.nntp.perl.org/group/perl.perl5.porters/2007/12/msg131709.html>
       for a description of how	this problem can bite the users.

       And see:	<http://rt.perl.org/rt3//Public/Bug/Display.html?id=22354> for
       a description of	the bug	and subsequent fix.

CONFIGURATION
       This Policy is not configurable except for the standard options.

AUTHOR
       Andrew Moore <amoore@mooresystems.com>

ACKNOWLEDGMENTS
       Adapted from policies by	Jeffrey	Ryan Thalhammer	<thaljef at cpan.org>,
       Thanks to Andy Lester, "<andy at	petdance.com>" for pointing out	this
       common problem.

COPYRIGHT
       Copyright (c) 2007-2011 Andy Lester <andy@petdance.com> and Andrew
       Moore <amoore@mooresystems.com>

       This library is free software; you can redistribute it and/or modify it
       under the terms of the Artistic License 2.0.

perl v5.24.1	 Perl::Critic::Policy::Bangs::ProhibitUselessRegexModifiers(3)

NAME | AFFILIATION | DESCRIPTION | CONFIGURATION | AUTHOR | ACKNOWLEDGMENTS | COPYRIGHT

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Perl::Critic::Policy::Bangs::ProhibitUselessRegexModifiers&sektion=3&manpath=FreeBSD+12.0-RELEASE+and+Ports>

home | help