Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

perl::critic::policy::builtinfunctions::prohibitvoidgrep(3) [centos 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)

Check Out this Related 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)
Man Page

12 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep help, how do i rewrite this

Thanks , franklin you method worked, i knew i had to use a while loop and getline in there just didnt know the proper order :) Hi everyone, im trying to make the following command line shorter by introducing a script that join up all the grep commands ./new1a < numbers.txt | grep -i -v '^a '... (5 Replies)
Discussion started by: weezybaby
5 Replies

2. Shell Programming and Scripting

Change word in list - PERL

Hi, probably a newbie question..... But there it goes. :o I have a list words. This list is taken out of a file with grep and cut. my @system = (`grep up system_list| cut -d':' -f1` ); system= sm00xp03 sm01ftp02 sm00ssh12 What I want to have is a list, with each of the words in the... (1 Reply)
Discussion started by: pmpx
1 Replies

3. Shell Programming and Scripting

Perl array grep

Hi, I have the following array. @a=( ,); and want to push @a,() if the 6 is not in the $a. This is simplified out of a longer script but im trying for days now and get sick of it. Can any of you help me on this. Cheers Markus (1 Reply)
Discussion started by: elvis00
1 Replies

4. Shell Programming and Scripting

Grep and map in perl

Hi guys, I'm trying to learn grep and map and having a little problem. Let's say I have a file which contains: Apple: abcdcabdadddbac I want to replace any combinations of three of abcd, thus when I do this: print grep {s/{3}/X/g} <F>; # will do the subtitution fine, output XXXX ... (1 Reply)
Discussion started by: new bie
1 Replies

5. Shell Programming and Scripting

Perl error. Help please

At this line in the perl script, @databases = `crs_stat | grep .db | awk -F. '{print $2}'`; It is throwing this error. Use of uninitialized value in concatenation (.) or string at ........ Looks like it didn't like the 2 dots I have in the statements. Is there a way to get around this... (3 Replies)
Discussion started by: MKNENI
3 Replies

6. 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

7. 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

8. 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

9. Shell Programming and Scripting

Need help with grep command in Perl

I am writing a Perl script that uses the grep command and instead of writing to the output file it just writes to the screen. #!/usr/bin/perl # # @ffiles = `ls CP*BUFFER*.dat`; foreach my $file (@ffiles){ @data = split(/./, $file); $filename = $data; $extension = $data; #print... (2 Replies)
Discussion started by: snillocnharas
2 Replies

10. Shell Programming and Scripting

Still thin Perl is long winded and cumbersome to use ...

grep " $1 " completelist if then echo "$1 not found." fi Is there a Perl solution that just as short sweet and fast ? (1 Reply)
Discussion started by: popeye
1 Replies

11. Shell Programming and Scripting

How to print the output side by side?

Hello, I know it is too simple but I do not know.. :/ #!/bin/bash for file in *.mp4 do echo "$file" ffmpeg -i $file 2>&1 | grep Duration |cut -d ' ' -f 4 | sed s/,// done Expected Output: NF_-_Let_You_Down-fbHbTBP_u7U.mp4 00:03:35.74 NF_-_WHY-zuJV-DAv_wE.mp4 00:03:11.87... (7 Replies)
Discussion started by: baris35
7 Replies

12. UNIX for Beginners Questions & Answers

How to print the "grep" result as specified keyword order?

I have a content.xls file as given below, NC_020815.1 1891831 1894692 virb4_A0A0H2X8Z4_ 1 954 1945 NC_020815.1 1883937 1886123 vird4_A0A0P9KA26_ 1 729 1379 NC_020815.1 2976151 2974985 virb10_H8FLU5_Ba 1 393 478 NC_020815.1 2968797 2967745 virb6_A0A0Q5GCZ4 5 398 499... (2 Replies)
Discussion started by: dineshkumarsrk
2 Replies