Sponsored Content
Full Discussion: string checking
Top Forums Shell Programming and Scripting string checking Post 302210884 by arghya_owen on Wednesday 2nd of July 2008 07:37:53 AM
Old 07-02-2008
Power string checking

please help me providing the code of checking a string pure numeric or not and pure alphanumeric or not
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Checking if string contains integer

G'day guys, first post so be gentle. I need help with some code to work out if a variable (string) contains any integers. The valid variable (string) must contain only letters. Also need to be able to work out if a variable contains only integers. Any help greatly appreciated. (7 Replies)
Discussion started by: haz
7 Replies

2. UNIX for Dummies Questions & Answers

Checking the header and trailer for a given string and if not found, exit out of the

hi, How to check a given file for a string and if it's not found, exit out ofthe script? e.g. a file Test123 is there whose header begins with #bt and trailer begins with #ed. I have to check if the header and trailer matches as above and if not, exit out of the script. How can we do it in... (2 Replies)
Discussion started by: er_ashu
2 Replies

3. Shell Programming and Scripting

Checking for the presence of a string within another string

How to check if a string in contained in another string ? Like Whether the String "brown" is contained in "A quick brown fox jumps over a lazy the dog" (1 Reply)
Discussion started by: hidnana
1 Replies

4. UNIX for Dummies Questions & Answers

Ksh Checking if string has 2 characters and does not contain digits?

How could I check if a string variable contains at least (or only) 2 characters, and check and make sure that the string does not contain any numeric digits?...I need to know how to do this as simple as possible. and I am using the Ksh shell. Thanks. (1 Reply)
Discussion started by: developncode
1 Replies

5. Shell Programming and Scripting

string checking

lets think str is a variable...how can i check it is pure alphabetic or not for numeric checking i have used echo $str|grep -v ] but the command echo $str|grep -v ] is not working (1 Reply)
Discussion started by: arghya_owen
1 Replies

6. Shell Programming and Scripting

Checking files in folder using starting string for filename

Hi, How do i check if there are any files present in the folder with some specific starting string. For eg :- I have used this where Source_File is filename parameter. if then return 2 fi But in my case the source file name is not constant. The only constant thing is... (10 Replies)
Discussion started by: chetancrsp18
10 Replies

7. Shell Programming and Scripting

Checking variable with specific string and stripping number from it.

I am parsing a file and I get differnt results everytime. Sometimes I get 12s sometimes I get 54m and sometime 3h.. v1=12s or v1=54m or v1=3h 12s - 12 seconds 54m - 54 minutes 3h - 3 hour I have to write a script in such a way that it whenever v1 is in minutes, I should strip "m"... (14 Replies)
Discussion started by: jayeshpatel
14 Replies

8. Shell Programming and Scripting

How to append string checking other same string?

Hi , I have a file likeA-0044150|ABC/Frito/ A-0044150|GFHU A-0150075|Bud Racing A-0187811|Bud Light A-0187811|RW&B signmaking I Want the o/p likeA-0044150|ABC/Frito/,GFHU A-0150075|Bud Racing A-0187811|Bud Light,RW&B signmaking (2 Replies)
Discussion started by: jagdishrout
2 Replies

9. Programming

Checking not empty string

I have a string s Are the following equivalent? if ( ! s.empty() ) { } if ( s ) { } (1 Reply)
Discussion started by: kristinu
1 Replies

10. Shell Programming and Scripting

What is the purpose of "-z" string checking?

what is the purpose of below specially "-z" string checking, how? pid=`ps ax |grep java` if (3 Replies)
Discussion started by: learnbash
3 Replies
Scalar::Number(3pm)					User Contributed Perl Documentation				       Scalar::Number(3pm)

NAME
Scalar::Number - numeric aspects of scalars SYNOPSIS
use Scalar::Number qw(scalar_num_part); $num = scalar_num_part($scalar); use Scalar::Number qw(sclnum_is_natint sclnum_is_float); if(sclnum_is_natint($value)) { ... if(sclnum_is_float($value)) { ... use Scalar::Number qw(sclnum_val_cmp sclnum_id_cmp); @sorted_nums = sort { sclnum_val_cmp($a, $b) } @floats; @sorted_nums = sort { sclnum_id_cmp($a, $b) } @floats; DESCRIPTION
This module is about the numeric part of plain (string) Perl scalars. A scalar has a numeric value, which may be expressed in either the native integer type or the native floating point type. Many values are expressible both ways, in which case the exact representation is insignificant. To fully understand Perl arithmetic it is necessary to know about both of these representations, and the differing behaviours of numbers according to which way they are expressible. This module provides functions to extract the numeric part of a scalar, classify a number by expressibility, and compare numbers across representations. This module is implemented in XS, with a pure Perl backup version for systems that can't handle XS. FUNCTIONS
Each "sclnum_" function takes one or more scalar numeric arguments to operate on. These arguments must be numeric; giving non-numeric arguments will cause mayhem. See "is_number" in Params::Classify for a way to check for numericness. Only the numeric value of the scalar is used; the string value is completely ignored, so dualvars are not a problem. Decomposition scalar_num_part(SCALAR) Extracts the numeric value of SCALAR, and returns it as a pure numeric scalar. The argument is permitted to be any scalar. Every scalar has both a string value and a numeric value. In pure string scalars, those resulting from string literals or string operations, the numeric value is determined from the string value. In pure numeric scalars, those resulting from numeric literals or numeric operations, the string value is determined from the numeric value. In the general case, however, a plain scalar's string and numeric values may be set independently, which is known as a dualvar. Non-plain scalars, principally references, determine their string and numeric values in other ways, and in particular a reference to a blessed object can stringify and numerify however the class wishes. This function does not warn if given an ostensibly non-numeric argument, because the whole point of it is to extract the numeric value of scalars that are not pure numeric. Classification sclnum_is_natint(VALUE) Returns a truth value indicating whether the provided VALUE can be represented in the native integer data type. If the floating point type includes signed zeroes then they do not qualify; the only zero representable in the integer type is unsigned. sclnum_is_float(VALUE) Returns a truth value indicating whether the provided VALUE can be represented in the native floating point data type. If the floating point type includes signed zeroes then an unsigned zero (from the native integer type) does not qualify. Comparison sclnum_val_cmp(A, B) Numerically compares the values A and B. Integer and floating point values are compared correctly with each other, even if there is no available format in which both values can be accurately represented. Returns -1, 0, +1, or undef, indicating whether A is less than, equal to, greater than, or not comparable with B. The "not comparable" situation arises if either value is a floating point NaN (not- a-number). All flavours of zero compare equal. This is very similar to Perl's built-in <=> operator. The only difference is the capability to compare integer against floating point (where neither can be represented exactly in the other's format). <=> performs such comparisons in floating point, losing accuracy of the integer value. sclnum_id_cmp(A, B) This is a comparison function supplying a total ordering of scalar numeric values. Returns -1, 0, or +1, indicating whether A is to be sorted before, the same as, or after B. The ordering is of the identities of numeric values, not their numerical values. If floating point zeroes are signed, then the three types (positive, negative, and unsigned) are considered to be distinct. NaNs compare equal to each other, but different from all numeric values. The exact ordering provided is mostly numerical order: NaNs come first, followed by negative infinity, then negative finite values, then negative zero, then unsigned zero, then positive zero, then positive finite values, then positive infinity. In addition to sorting, this function can be useful to check for a zero of a particular sign. BUGS
In Perl 5.6, if configured with a wider-than-usual native integer type such that there are native integers that can't be represented exactly in the native floating point type, it is not always possible to distinguish between integer and floating point values in pure Perl code. In order to get the full benefit of either type, one is expected (by the numeric semantics) to know in advance which of them one is using. The pure Perl version of this module can't operate on such a system, but the XS version works fine. This problem is resolved by Perl 5.8's new numeric semantics. SEE ALSO
Data::Float, Data::Integer, perlnumber(1) AUTHOR
Andrew Main (Zefram) <zefram@fysh.org> COPYRIGHT
Copyright (C) 2007, 2009, 2010 Andrew Main (Zefram) <zefram@fysh.org> LICENSE
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2011-11-15 Scalar::Number(3pm)
All times are GMT -4. The time now is 09:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy