Sponsored Content
Full Discussion: Those simple one liners
The Lounge What is on Your Mind? Those simple one liners Post 302791537 by ahamed101 on Monday 8th of April 2013 04:32:40 PM
Old 04-08-2013
Those simple one liners

I wanted to say LOL and punch my face when I saw post#11 (where Don_Cragun even reduced the string manipulation with a simple regex) in the thread https://www.unix.com/shell-programmin...ilename-2.html

I mean, when things can be done with just a one liner, sometimes I tend to forgot those simple things and go for unwanted iterations.

Does this happen to you? You write a 10 liner and "HE" comes in with a one liner and you will be like "what?". Can't agree if someone says it cause of experience not in this case at least. May be our brain misses something sometimes and thinks too complex?

--ahamed
 

4 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

invaluable resource for shell one liners and more

Hi all, This link might help whom is seeking a quick solutions for thier daily shell needs. linkAll commands | commandlinefu.com (1 Reply)
Discussion started by: h@foorsa.biz
1 Replies

2. Shell Programming and Scripting

awk - one liners

Guys, I have a requirement like this. A file has >5K records always. Separated by "|", it has 30 fields for each line. In some lines, I am getting an odd field. say, the 15th field is supposed to be 2 characters but comes in as >2. In this case, for resolving this I need to copy the value of... (6 Replies)
Discussion started by: PikK45
6 Replies

3. Shell Programming and Scripting

awk one liners into a nice script

Hi All, I got some awk one liners, how can i split it all into a nice script? Got these: gzcat capgw0.log-201308161376632741.gz | sed -n '/2013-08-16 05:56:/,/2013-08-16 05:58:/p' > timebased.log awk -F":|," 'FNR==NR && /INFO - AId:/ {a=$0;next} END {for (i in a) print i "|" a}'... (8 Replies)
Discussion started by: batka
8 Replies

4. What is on Your Mind?

One liners, quick rant...

Hi fellas and fella-esses... There are numerous threads on here where people ask for, and often expect, solutions to difficult problems solved using _one_liners_. Why do they insist as such when it is virtually no different in execution time with well thought out indented code? Is it me... (12 Replies)
Discussion started by: wisecracker
12 Replies
Perl::Critic::Policy::BuiltinFunctions::ProhibitComplexMUsernContributed Perl DoPerl::Critic::Policy::BuiltinFunctions::ProhibitComplexMappings(3)

NAME
Perl::Critic::Policy::BuiltinFunctions::ProhibitComplexMappings - Map blocks should have a single statement. AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
The map function can be confusing to novices in the best of circumstances. Mappings with multiple statements are even worse. They're also a maintainer's nightmare because any added complexity decreases readability precipitously. Why? Because map is traditionally a one-liner converting one array to another. Trying to cram lots of functionality into a one-liner is a bad idea in general. The best solutions to a complex mapping are: 1) write a subroutine that performs the manipulation and call that from map; 2) rewrite the map as a for loop. CAVEATS
This policy currently misses some compound statements inside of the map. For example, the following code incorrectly does not trigger a violation: map { do { foo(); bar() } } @list CONFIGURATION
By default this policy flags any mappings with more than one statement. While we do not recommend it, you can increase this limit as follows in a .perlcriticrc file: [BuiltinFunctions::ProhibitComplexMappings] max_statements = 2 AUTHOR
Chris Dolan <cdolan@cpan.org> CREDITS
Initial development of this policy was supported by a grant from the Perl Foundation. COPYRIGHT
Copyright (c) 2007-2011 Chris Dolan. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.3 2014-06-09 Perl::Critic::Policy::BuiltinFunctions::ProhibitComplexMappings(3)
All times are GMT -4. The time now is 01:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy