Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

perl::critic::policy::subroutines::prohibitreturnsort(3pm) [debian man page]

Perl::Critic::Policy::Subroutines::ProhibitReturnSort(3pUser Contributed Perl DocumentatPerl::Critic::Policy::Subroutines::ProhibitReturnSort(3pm)

NAME
Perl::Critic::Policy::Subroutines::ProhibitReturnSort - Behavior of "sort" is not defined if called in scalar context. AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
The behavior of the builtin "sort" function is not defined if called in scalar context. So if you write a subroutine that directly "return"s the result of a "sort" operation, then you code will behave unpredictably if someone calls your subroutine in a scalar context. This Policy emits a violation if the "return" keyword is directly followed by the "sort" function. To safely return a sorted list of values from a subroutine, you should assign the sorted values to a temporary variable first. For example: sub frobulate { return sort @list; # not ok! @sorted_list = sort @list; return @sort # ok } KNOWN BUGS
This Policy is not sensitive to the "wantarray" function. So the following code would generate a false violation: sub frobulate { if (wantarray) { return sort @list; } else{ return join @list; } } CONFIGURATION
This Policy is not configurable except for the standard options. CREDITS
This Policy was suggested by Ulrich Wisser and the <http://iis.se> team. 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-07 Perl::Critic::Policy::Subroutines::ProhibitReturnSort(3pm)

Check Out this Related Man Page

Perl::Critic::Policy::ControlStructures::ProhibitUntilBlUser(Contributed Perl DocPerl::Critic::Policy::ControlStructures::ProhibitUntilBlocks(3pm)

NAME
Perl::Critic::Policy::ControlStructures::ProhibitUntilBlocks - Write "while(! $condition)" instead of "until($condition)". AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
Conway discourages using "until" because it leads to double-negatives that are hard to understand. Instead, reverse the logic and use "while". until($condition) { do_something() } #not ok until(! $no_flag) { do_something() } #really bad while( ! $condition) { do_something() } #ok This Policy only covers the block-form of "until". For the postfix variety, see "ProhibitPostfixControls". CONFIGURATION
This Policy is not configurable except for the standard options. SEE ALSO
Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls 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-07 Perl::Critic::Policy::ControlStructures::ProhibitUntilBlocks(3pm)
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

printing rich text

I need to find a way to print a rich text document through unix. I don't care how it's done--i.e. some sort of conversion to a different format (postscript?) or through some sort of software. Any reasonable, quick solution would be appreciated. Thanks. Angela (3 Replies)
Discussion started by: angthelaw
3 Replies

2. Programming

sort function

do any one knows where i can find an implementation in c for the sort function (2 Replies)
Discussion started by: dbargo
2 Replies

3. Shell Programming and Scripting

sort

Hello, How would I sort a file in reverse,? In other words, my file has that the date for example as : bob 25years. I would like it sorted this way : 25years bob. I did a man on sort but nothing really that helps. Thanks. (4 Replies)
Discussion started by: dxrmroue
4 Replies

4. Shell Programming and Scripting

sort can't stat error.

I am using the command below to sort unique a file and I keep getting this error that sort can't stat. Error: sort: can't stat /xxxx/xxxxx/2005/xxxxxx/out_20050602155231/test.txt: No such file or directory Does anybody have an idea when this error could occur. Thanks, Radhika. if ... (5 Replies)
Discussion started by: radhika
5 Replies

5. What is on Your Mind?

Whats Behind Your Name?

Looking at the member list, there are alot of interesting names, some unique, some bizarre, and some that are just plain. How did you come by your name? Why did you choose your label? Me? Well, I wish I could change mine. I chose Google because thats how I stumbled upon this site. I wasn't sure... (66 Replies)
Discussion started by: google
66 Replies

6. Programming

Writing c code for who | sort | lp

Hi, Can any one please let me know the code for implementing who | sort | lp Basically I want to implent pipe here. The program can use the existing who, sort and lp Also please let me know How many processes are created in Unix when the following commands are executed? $ ls... (17 Replies)
Discussion started by: yeheyaansari
17 Replies

7. Shell Programming and Scripting

[B]Perl sort quick question[/B]

I've done a quick Google about this, but could not find the answer I want. Say, there is an array like this: @A = qw(cd1 a1 ef a2 hij a12 b2 b4 b22); I want to sort the array in the first order: @sorted = qw(a1 a12 a2 b2 b22 b4 cd1 ef hij); And second order: @sorted = qw(a1 a2 a12 b2 b4... (5 Replies)
Discussion started by: zx1106
5 Replies

8. Shell Programming and Scripting

Perl function to sort a file based on key fields

Hi, I am new to PERL.I want to sort all the lines in a file based on 1,2 and 4th filelds. Can U suggest me a command/function in perl for this operation.. (5 Replies)
Discussion started by: karthikd214
5 Replies

9. Shell Programming and Scripting

sort in perl

Hi Is there any way I could reproduce the following code in perl 5.8: sort -u FILE | sort -t: -k1,1 -k2n which sorts by unicity first, then by first key, then by second key in numeric format. What I have now is @sort_array=uniq sort @sort_array; after the contents of my... (5 Replies)
Discussion started by: Indalecio
5 Replies

10. Shell Programming and Scripting

Trying to sort data

Im trying to sort all this data. I need to get a list out of the data (websites) and just list them out can anyone point me in the right direction. Im working with dans guardian. 2009.6.10 6:26:50 - 192.168.42.200... (5 Replies)
Discussion started by: darknirvana
5 Replies

11. Shell Programming and Scripting

sort text file

HI all i have a text file file1 like this 004002004545454000001 041002004545222000002 006003008751525000003 007003008751352000004 006003008751142000005 004001005745745000006 i want to sort the file according to position 1-5 and secondary sort by the last position of file 16-21... (4 Replies)
Discussion started by: naamas03
4 Replies

12. UNIX for Dummies Questions & Answers

Does this statement of code mean.....

Good morning, I am 100% mew to Unix and am trying to troubleshoot why a pgm written 3 years ago, suddenly is not working properly. It is part Perl with some UNIX commands thrown in. I need to verify what the UNIX commands are doing before I can continue with my other troubleshooting. print... (7 Replies)
Discussion started by: jaacmmason
7 Replies

13. UNIX for Advanced & Expert Users

Weird "sort" behavior

Hi, I'm trying to sort a text file "test": S12 S_S12 S_S1_12 S15 S_N15 S_N1_15 By "sort test", I get: S12 S15 S_N1_15 S_N15 S_S1_12 S_S12 It seems weird: Comparing Line 2 and Line 3, it must be that '-' is bigger than '1'; however, comparing Line 3 and Line 4, it seems that... (3 Replies)
Discussion started by: intermilan
3 Replies

14. UNIX for Beginners Questions & Answers

How to sort and get last value?

hi, would you guys help me ? i have a file with some list, and i want to sort the list and get last value. ex: cat testing.csv $ cat testing.csv a,1 a,2 a,3 d,5 b,3 c,3 c,4 etc i want to get value like this : a,3 b,3 (5 Replies)
Discussion started by: kivale
5 Replies

15. UNIX for Beginners Questions & Answers

Perl: Can someone please explain this code "sort { $a <=> $b } @unsorted"

@sorted = sort { $a <=> $b } @unsorted; I am having hard time understanding how this works? I know the output but interested to know the working. Thanks in advance. (2 Replies)
Discussion started by: Tanu
2 Replies