Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

perl::critic::policy::regularexpressions::requirebracesformultil(3) [centos man page]

Perl::Critic::Policy::RegularExpressions::RequireBracesFUserlContributed PerPerl::Critic::Policy::RegularExpressions::RequireBracesForMultiline(3)

NAME
Perl::Critic::Policy::RegularExpressions::RequireBracesForMultiline - Use "{" and "}" to delimit multi-line regexps. AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
Long regular expressions are hard to read. A good practice is to use the "x" modifier and break the regex into multiple lines with comments explaining the parts. But, with the usual "//" delimiters, the beginning and end can be hard to match, especially in a "s///" regexp. Instead, try using "{}" characters to delimit your expressions. Compare these: s/ <a s+ href="([^"]+)"> (.*?) </a> /link=$1, text=$2/xms; vs. s{ <a s+ href="([^"]+)"> (.*?) </a> } {link=$1, text=$2}xms; Is that an improvement? Marginally, but yes. The curly braces lead the eye better. CONFIGURATION
There is one option for this policy, "allow_all_brackets". If this is true, then, in addition to allowing "{}", the other matched pairs of "()", "[]", and "<>" are allowed. CREDITS
Initial development of this policy was supported by a grant from the Perl Foundation. AUTHOR
Chris Dolan <cdolan@cpan.org> COPYRIGHT
Copyright (c) 2007-2011 Chris Dolan. Many rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module perl v5.16.3 2014-06-Perl::Critic::Policy::RegularExpressions::RequireBracesForMultiline(3)

Check Out this Related Man Page

Perl::Critic::Policy::RegularExpressions::RequireDotMatcUsertContributed PerPerl::Critic::Policy::RegularExpressions::RequireDotMatchAnything(3pm)

NAME
Perl::Critic::Policy::RegularExpressions::RequireDotMatchAnything - Always use the "/s" modifier with regular expressions. AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
When asked what "." in a regular expression means, most people will say that it matches any character, which isn't true. It's actually shorthand for "[^ ]". Using the "s" modifier makes "." act like people expect it to. my $match = m< foo.bar >xm; # not ok my $match = m< foo.bar >xms; # ok CONFIGURATION
This Policy is not configurable except for the standard options. NOTES
Be cautious about slapping modifier flags onto existing regular expressions, as they can drastically alter their meaning. See <http://www.perlmonks.org/?node_id=484238> for an interesting discussion on the effects of blindly modifying regular expression flags. AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. perl v5.14.2 2012-06-Perl::Critic::Policy::RegularExpressions::RequireDotMatchAnything(3pm)
Man Page

4 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tagged regular expressions(TRE) in unix

Hi gurus, Can any of you suggest any good link for going through tagged regular expressions for unix.I am finding it quite critical and need some help from all gurus to know this better. Any good link containing detailed examples with descriptions would do i guess. thanks in advance. (0 Replies)
Discussion started by: navojit dutta
0 Replies

2. Shell Programming and Scripting

q with Perl Regex

For a programming exercise, I am mean to design a Perl script that detects double letters in a text file. I tried the following expressions # Check for any double letter within the alphabet /+/ # Check for any repetition of an alphanumeric character /\w+/ Im aware that the... (8 Replies)
Discussion started by: JamesGoh
8 Replies

3. Shell Programming and Scripting

Perl - How to search a text file with multiple patterns?

Good day, great gurus, I'm new to Perl, and programming in general. I'm trying to retrieve a column of data from my text file which spans a non-specific number of lines. So I did a regexp that will pick out the columns. However,my pattern would vary. I tried using a foreach loop unsuccessfully.... (2 Replies)
Discussion started by: Sp3ck
2 Replies

4. Shell Programming and Scripting

A Perl regexp to validate arithmetic expressions

Can a Perl regexp validate arithmetic expressions? I say yes. Here is my Perl regexp to validate arifmetic expressions: #!perl -w use strict; use re 'eval'; my @testexpr=( # Valid arifmetic expressions '+3', '-(3/4+(-2-3)/3)', '(-((3)))', '-(+1+2)*(3/(1-2))/((-3))', # Invalid (from... (3 Replies)
Discussion started by: cronc
3 Replies