Sponsored Content
Top Forums Shell Programming and Scripting Perl ? - How to find and print the lowest and highest numbers punched in by the user? Post 302180054 by cbkihong on Saturday 29th of March 2008 12:04:49 PM
Old 03-29-2008
List::Util has the "max" and "min" functions that you can use to directly find the maximum and minimum given a list of numbers. It's better not to reinvent the wheel if these functionalities are taken care of by a core module available in all Perl installations.

List::Util - perldoc.perl.org
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

the smallest number from 90% of highest numbers from all numbers in file

Hello All, I am having problem to find what is the smallest number from 90% of highest numbers from all numbers in file. I am having file with thousands of lines and hundreds of columns. I am familiar mainly with bash but I am open to whatever suggestion witch will lead to the solutions. If I... (11 Replies)
Discussion started by: Apfik
11 Replies

2. Shell Programming and Scripting

print every 20 lines the lowest number

Hello all, How can I find the lowest number every 10 lines? For example i have a list name1 -0.1 name2 2 name3 3 name4 -3 name5 1 name6 2 name7 34 name8 34 (6 Replies)
Discussion started by: TheTransporter
6 Replies

3. Shell Programming and Scripting

finding lowest numbers

i want to basically get the lowest numbers from a list ... for example my input file is .... 1 2 3 6 7 8 9 10 11 13 Now i want to create a script or a one liner which i can use like this ... for example ..../getlowest 3 --> this gives me the next 3 lowest numbers which... (6 Replies)
Discussion started by: greycells
6 Replies

4. Shell Programming and Scripting

Selecting lowest and highest values in columns 1 and 2, based on subsets in column 3

Hi, I have a file with the following columns: 361459 447394 CHL1 290282 290282 CHL1 361459 447394 CHL1 361459 447394 CHL1 178352861 178363529 AGA 178352861 178363529 AGA 178363657 178363657 AGA Essentially, using CHL1 as an example. For any line that has CHL1 in... (2 Replies)
Discussion started by: hubleo
2 Replies

5. Shell Programming and Scripting

top 10 highest and lowest percentile from a column

Hi, I want to extract the the top 10 and lowest 10 percentile for a column of values. For example in column 2 for this file: JOE 1 JAY 5 JAM 6 JIL 8 JIB 4 JIH 3 JIG 2 JIT 7 JAM 9 MAR 10 The top 10 lowest will be: JOE 1 and the top 10 highest will be: (2 Replies)
Discussion started by: kylle345
2 Replies

6. Shell Programming and Scripting

Find common numbers and print yes or no

Hi I have 2 files with following data First file, sp|Q676U5|A16L1_HUMAN, Autophagy-related protein 16-1 OS=Homo sapiens GN=ATG16L1 PE=1 SV=2, Maximum coiled-coil residue probability: 0.657 in position 163. Maximum dimeric residue probability: 0.288 in position 163. ... (1 Reply)
Discussion started by: manigrover
1 Replies

7. Homework & Coursework Questions

program to find and print a Fibonacci sequence of numbers. --Errors

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am trying to convert a C language program over to Sparc Assembley and I am getting Undefined first referenced... (4 Replies)
Discussion started by: kenjiro310
4 Replies

8. Shell Programming and Scripting

Perl: find next available lowest number that is available in two arrays

Hi there. I have a number allocation problem whereby I have 2 arrays built from 2 different sources. The arrays will just contain a listed of sorted numbers @a 1 7 10 14 15 16 @b 1 7 10 11 14 15 16 (2 Replies)
Discussion started by: hcclnoodles
2 Replies

9. UNIX for Dummies Questions & Answers

Awk, highest and lowest value of a column

Hi again! I am still impressed how fast I get a solution for my topic "average specific column value awk" yesterday. The associative arrays in awk work fine for me! But now I have another question for the same project. Now I have a list like this 1 -0.1 1 0 1 0.1 2 0 2 0.2 2 -0.2 How... (10 Replies)
Discussion started by: bjoern456
10 Replies

10. Shell Programming and Scripting

Sort from highest to lowest number

Hi Guys, I am looking for a way to sort the output below from the "Inuse" count from Highest to Lowest. Is it possible? Thanks in advance. user1 0.12 0.06 0 0.12 User Inuse Pin Pgsp Virtual Unit:... (4 Replies)
Discussion started by: jaapar
4 Replies
Scalar::Util::Numeric(3pm)				User Contributed Perl Documentation				Scalar::Util::Numeric(3pm)

NAME
Scalar::Util::Numeric - numeric tests for Perl scalars SYNOPSIS
use Scalar::Util::Numeric qw(isnum isint isfloat); foo($bar / 2) if (isnum $bar); if (isint $baz) { # ... } elsif (isfloat $baz) { # ... } DESCRIPTION
This module exports a number of wrappers around perl's builtin "grok_number" function, which returns the numeric type of its argument, or 0 if it isn't numeric. TAGS
All of the functions exported by Scalar::Util::Numeric can be imported by using the ":all" tag: use Scalar::Util::Numeric qw(:all); EXPORTS
isnum isnum ($val) Returns a nonzero value (indicating the numeric type) if $val is a number. The numeric type is a conjunction of the following flags: 0x01 IS_NUMBER_IN_UV (number within UV range - not necessarily an integer) 0x02 IS_NUMBER_GREATER_THAN_UV_MAX (number is greater than UV_MAX) 0x04 IS_NUMBER_NOT_INT (saw . or E notation) 0x08 IS_NUMBER_NEG (leading minus sign) 0x10 IS_NUMBER_INFINITY (Infinity) 0x20 IS_NUMBER_NAN (NaN - not a number) isint isuv isbig isfloat isneg isinf isnan The following flavours of "isnum" (corresponding to the flags above) are also available: isint isuv isbig isfloat isneg isinf isnan "isint" returns -1 if its operand is a negative integer, 1 if it's 0 or a positive integer, and 0 otherwise. The others always return 1 or 0. SEE ALSO
o "type" in autobox o Data::Types o Params::Classify o Params::Util o Scalar::Util o String::Numeric VERSION
0.22 AUTHORS
o chocolateboy <chocolate@cpan.org> o Michael G Schwern <schwern@pobox.com> COPYRIGHT
Copyright (c) 2005-2010, chocolateboy. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. perl v5.14.2 2010-08-25 Scalar::Util::Numeric(3pm)
All times are GMT -4. The time now is 12:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy