Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

perl::critic::policy::builtinfunctions::requireblockgrep(3) [centos man page]

Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrepUser Contributed Perl DocumentaPerl::Critic::Policy::BuiltinFunctions::RequireBlockGrep(3)

NAME
Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrep - Write "grep { $_ =~ /$pattern/ } @list" instead of "grep /$pattern/, @list". AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
The expression forms of "grep" and "map" are awkward and hard to read. Use the block forms instead. @matches = grep /pattern/, @list; #not ok @matches = grep { /pattern/ } @list; #ok @mapped = map transform($_), @list; #not ok @mapped = map { transform($_) } @list; #ok CONFIGURATION
This Policy is not configurable except for the standard options. SEE ALSO
Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap 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.16.3 2014-06-09 Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrep(3)

Check Out this Related Man Page

Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrepUser Contributed Perl DocumentaPerl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep(3)

NAME
Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep - Don't use "grep" in void contexts. AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
"map" and "grep" are intended to be pure functions, not mutators. If you want to iterate with side-effects, then you should use a proper "for" or "foreach" loop. grep{ print frobulate($_) } @list; #not ok print map{ frobulate($_) } @list; #ok grep{ $_ = lc $_ } @list; #not ok for( @list ){ $_ = lc $_ }; #ok map{ push @frobbed, frobulate($_) } @list; #not ok @frobbed = map { frobulate($_) } @list; #ok CONFIGURATION
This Policy is not configurable except for the standard options. 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.16.3 2014-06-09 Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep(3)
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

grep problem

SQL*Plus: Release 9.2.0.8.0 - Production on Mon Jul 21 07:53:35 2008 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to: Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production With the Partitioning option JServer Release 9.2.0.8.0 - Production SQL>... (3 Replies)
Discussion started by: infyanurag
3 Replies

2. Shell Programming and Scripting

grep using Perl

I'm using perl to do a grep of each line in a vendor file and find its occurrences in a specific directory. Any values found is saved in @dir. .....(file opened, etc.) .... while ($line=<FILE>){ @dir = `grep $line * `; } It's the specific usage of the system grep that I'm having... (7 Replies)
Discussion started by: gavineq
7 Replies

3. UNIX for Dummies Questions & Answers

Getting unique list of numbers using grep

Hi, I am going to fetch a list of numbers that starts with "0032" from a file with a format like the given below: " 0032459999 0032458888 0032457777 0032451111 0032452222 0032453333 0032459999 0032458888 0032457777 0032451111 0032452222 0032453333 " I want to get a unique... (6 Replies)
Discussion started by: tinku
6 Replies

4. Shell Programming and Scripting

Perl pattern matching!!

Hi experts, I have many occurances of the following headers in a file. I need to grep for the word changed/inserted in the header, calculate the difference between the two numbers and list the count incrementally. Headers in a file look like this: ------------------- ---------------------... (6 Replies)
Discussion started by: nmattam
6 Replies

5. Shell Programming and Scripting

pattern grep using Perl in .TSV file

Hi All, I have a .TSV extension file having ~1 Gig data and I need to grep a pattern in that file using perl. I am not able to read the file using perl any suggestions on this/ If I Change the format my data gets mismangled so I am bothered about using specific format as well. #!... (3 Replies)
Discussion started by: vmsenthil
3 Replies

6. Shell Programming and Scripting

Perl question

Hi I am trying to issue a system call in my Perl script based on the presence of certain pattern in the other file. The pattern is stored in the variable. Can somebody help me with the syntax. This is an example: #!/usr/bin/perl open(MYFILE, "/t1/bin/t1syschk.cmd"); $pattern=cmprsvc; system... (3 Replies)
Discussion started by: aoussenko
3 Replies

7. Shell Programming and Scripting

Unix Shell scripting, removing hex 0d 0a

hi, I have a file with data like this : 5963491,11926750,Policy Endorsement 1 Policy Endorsement 2 Policy Endorsement 3 Policy Endorsement 4 Policy Endorsement 5 Policy Endorsement 6 Policy Endorsement 7 5963492,11926751,Product.Quote... (10 Replies)
Discussion started by: mrsindhe87
10 Replies

8. Shell Programming and Scripting

grep or awk looking for repeating text

I am looking for a way to find the below pattern in text. 777777,111,08-20-2011 111111,222,08-20-2011 777777,111,07-24-2011 777777,222,07-24-2011 111111,222,07-22-2011 I would like to find a way to print every line in a file where the first 6 numbers match and there is different... (6 Replies)
Discussion started by: ffdstanley
6 Replies

9. Shell Programming and Scripting

Perl + and Grep

Hi All i have this script that uses glob to look in /var/log/messages.* my @messagefiles = glob "/var/log/messages.*"; and the code that uses it is this grep { /NVRM: Xid/ } @messages) but this spits out this /var/log/messages-20111030:Oct 25 13:43:04 brent kernel: NVRM:... (10 Replies)
Discussion started by: ab52
10 Replies

10. Shell Programming and Scripting

Perl extract number from file & write to file

I have 1 file that has elements as follows. Also the CVR(10) and the word "SAUCE" only appear once in the file so maybe a grep command would work? file1 CVR( 9) = 0.385E+05, ! VEHICLE CVR(10) = 0.246E+05, ! SAUCE CVR(11) = 0.162E+03, ! VEHICLE I need to extract the... (6 Replies)
Discussion started by: austinj
6 Replies

11. Shell Programming and Scripting

grep command

I have a text file that I try to grep for a string. It has both 2005 and 20055 string. How do I grep for 2005 only? I try this grep "2005]" myfile This works fine on Linux but this same command doesn't work on Unix. Please help! Please use code tags! (11 Replies)
Discussion started by: kathyh
11 Replies

12. Shell Programming and Scripting

Help with Linux hardware fault script in Perl

Hello, I am working on a Perl script to run from an AIX Nim server to extract hardware errors from our Linux server using various forms of grep statements - I have all my hosts in a text file and a command is run from the nim server to each host to pull out data from /var/log/messages and... (5 Replies)
Discussion started by: neilh1704
5 Replies

13. UNIX for Dummies Questions & Answers

Grep in Perl - Searching through multiple files

I'm attempting to use grep in Perl with very little success. What I would like to do in Perl is get the output of the following grep code: grep -l 'pattern' * This gives me a list of all the files in a directory that contain the pattern that was searched. My attempts to do this in Perl... (4 Replies)
Discussion started by: WongSifu
4 Replies

14. Shell Programming and Scripting

Displaying the first field if the second field matches the pattern using Perl

Hi, I am trying with the below Perl command to print the first field when the second field matches the given pattern: perl -lane 'open F, "< myfile"; for $i (<F>) {chomp $i; if ($F =~ /patt$/) {my $f = (split(" ", $i)); print "$f";}} close F' dummy_file I know I can achieve the same with the... (7 Replies)
Discussion started by: royalibrahim
7 Replies

15. Shell Programming and Scripting

Using perl to grep a list of patterns from an input file

I have been struggling to grep a file of NGrams (basically clusters of consonants or Consonant and Vowel) acting as a pattern file from an Input file which contains a long list of words, one word per line. The script would do two things: Firstly read a text pattern from a large file of such... (5 Replies)
Discussion started by: gimley
5 Replies