get the perl version (decimal value comparision)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting get the perl version (decimal value comparision)
# 1  
Old 04-25-2012
get the perl version (decimal value comparision)

Hi All,
can you pls throw some light for below logic

-> Check the perl version
-> if the version is greater than or equal to 5.8
-> proceed to next step
-> else fail

Regards
Kamal
# 2  
Old 04-25-2012
How about this using bash:

Code:
#!/bin/bash
IFS=' .v' V=( $(perl --version) )
[ ${V[3]:-0} -le 5 ] && [ ${V[3]:-0} -ne 5 -o ${V[4]} -lt 8 ] && exit 1
echo "Perl version ${V[3]}.${V[4]}.${V[5]} is acceptable"

Or with ksh:
Code:
#!/bin/ksh
OLDIFS=$IFS
IFS=' .v'
set -A V $(perl --version)
IFS=$OLDIFS
 
[ ${V[3]:-0} -le 5 ] && [ ${V[3]:-0} -ne 5 -o ${V[4]} -lt 8 ] && exit 1
echo "Perl version ${V[3]}.${V[4]}.${V[5]} is acceptable"


Last edited by Chubler_XL; 04-25-2012 at 11:26 PM..
This User Gave Thanks to Chubler_XL For This Post:
# 3  
Old 04-25-2012
thanks for your reply, i tried ksh code and its working fine ....

Regards
Kamal

Last edited by kamauv234; 04-26-2012 at 12:12 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Ignoring decimal in comparision

HI All, I am having a requirement on ignoring mismatch on 2 file File 1: A,B,US,10.02 A,B,US,10.02 A,B,US,11.02 File 2: A,B,US,10.02 A,B,US,10.00 A,B,US,12.02 Here I want to ignore the decimal . If I do diff it is showing File1 AND File2 are different.If I ignore the... (2 Replies)
Discussion started by: arunkumar_mca
2 Replies

2. Shell Programming and Scripting

Perl to extract whole number or decimal in regex

In the perl below I am trying to extract and print specic values from patterns using multiple regex. One of the patterns AF= may be a whole number or a decimal but I can not seem to capture both. I think it is the regex .*AF=(\d+\.\d+); as it is expecting a #.#### and it may only be a #. I tried... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Shell Programming and Scripting

Check for decimal point and add it at the end if its not there using awk/perl

I have test.dat file with values given below: 20150202,abc,,,,3625.300000,,,,,-5,,,,,,,,,,,,,,,,,,,,,, 20150202,def,,,,32.585,,,,,0,,,,,,,,,,,,,,,,,,,,,, 20150202,xyz,,,,12,,,,,0.004167,,,,,,,,,,,,,,,,,,,,,, My expected output is shown below: ... (1 Reply)
Discussion started by: nvk_vinoth
1 Replies

4. Programming

Urgent help needed.. C++ program to convert decimal to hexa decimal

Hi , seq can be 0...128 int windex = seq / 8; int bindex = seq % 8; unsigned char bitvalue = '\x01' << (7-bindex) ; bpv.bitmapvalue = bitvalue; This is the part of a program to convert decimal to bitmap value of hexadecimal. I want this to change to convert only to... (1 Reply)
Discussion started by: greenworld123
1 Replies

5. Shell Programming and Scripting

Linux kernel version comparision method

Hi All, I am preparing a precheck script for my oracle DB installation. I am setting an expected version value, actual version can be greater than the expected version or equal to it. I am using the below logic to test this. expected=2.6.32-279.el6.x86_64 received=$(uname -r) ... (5 Replies)
Discussion started by: veeresh_15
5 Replies

6. Shell Programming and Scripting

perl: comparision of field line by line in two files

Hi everybody, First I apologize if my question seems demasiad you silly, but it really took 4 days struggling with this, I looked at books, forums ... And Also ask help to a friend that is software developer and he told me that it is a bad idea do it by perl... but this is my problem. I moved to... (8 Replies)
Discussion started by: Thelost
8 Replies

7. Homework & Coursework Questions

Decimal to BCD (Binary Coded Decimal)

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: Design an algorithm that accepts an input a decimal number and converts it into BCD (Binary... (2 Replies)
Discussion started by: caramba
2 Replies

8. UNIX for Dummies Questions & Answers

Decimal to BCD (Binary Coded Decimal)

Anybody please help me... Design an algorithm that accepts an input a decimal number and converts it into BCD (Binary Coded Decimal) representation. Also, draw its Flow Chart. This is a unix qn... plz post algorithm for that :confused: (1 Reply)
Discussion started by: caramba
1 Replies

9. Shell Programming and Scripting

error while doing decimal comparision in shell

a=10 b=10.6 c=$(echo "$a - $b" | bc) if ] echo "success" else echo "failure" fi while executing the above sample code, am getting the below error: seems unix is comparing .6 with 0 instead of 0.6 with 0. can anyone help me in solving this ? regards, (7 Replies)
Discussion started by: cmaroju
7 Replies
Login or Register to Ask a Question