Visit Our UNIX and Linux User Community

removing DOT by using perl

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting removing DOT by using perl
# 1  
Old 09-18-2009
removing DOT by using perl

Hi Friends,
I have a variable which has a number (e.g. 12.1234). I want to remove "." (dot) from that number i.e. 121234
I want to do this using perl.
Can you please guide me
Thank you
# 2  
Old 09-18-2009
$ perl -le '$x=12.1234; print "Before: $x"; $x=~s/\.//; print "After:  $x"'
Before: 12.1234
After:  121234

# 3  
Old 09-18-2009
$var = 12.1234;
$str = substr $var,0,index($var,".");
$str2 = substr $var,index($var,".")+1;
print $str.$str2;

Previous Thread | Next Thread
Test Your Knowledge in Computers #1
Difficulty: Medium
The UNIX and Linux Forums ( was founded in 1985.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with removing duplicate entries with awk or Perl

Hi, I have a file which looks like:ke this : chr1 11127067 11132181 89 chr1 11128023 11128311 chr1 11130990 11131025 chr1 11127067 11132181 89 chr1 11128023 11128311 chr1 11131583... (22 Replies)
Discussion started by: Amit Pande
22 Replies

2. Shell Programming and Scripting

perl dot escaping issue

Hello, I'm trying to figure out why this perl command does not work. I want to split a string on dot delimiter. If I try with colon the result is fine: > echo -n "hello:world" | perl -F/:/ -ane 'print "$F\n"' >world As expected I get the good result, but by typing: > echo -n... (3 Replies)
Discussion started by: Dedalus
3 Replies

3. Shell Programming and Scripting

Replace dot with semicolon in PERL

Hi, I have a file in PERL in the following pattern filename| 06-Dec-11 PM filename1| 06-Dec-11 PM I need to replace .(dot) with :(semicolon) in the timestamp value of the file How can this be done. Any help will be appreciated Thanks in advance (5 Replies)
Discussion started by: irudayaraj
5 Replies

4. Shell Programming and Scripting

removing \n in PERL from the data fetched from db

Hi I am fetching data from table which contains SQL query like this into a variable $qry SELECT ABC, DEF WHERE (XYZ = 'Normalization' or ABC_TYPE = 'DEF') and lookup_port like 'ABAC%' My requirement is I need to fetch a where clause to a variable if ( $qry =~... (3 Replies)
Discussion started by: gvk25
3 Replies

5. Shell Programming and Scripting

script in perl for removing strings between a file

I have file that looks like: ATOM 2517 O VAL 160 8.337 12.679 -2.487 ATOM 2518 OXT VAL 160 7.646 12.461 -0.386 TER ATOM 2519 N VAL 161 -14.431 5.789 -25.371 ATOM 2520 H1 VAL 161 -15.336 5.698 -25.811 ATOM 2521 H2 VAL 161 -13.416 10.529 17.708 ATOM 2522 H3 VAL 161 -14.363 ... (4 Replies)
Discussion started by: kanikasharma
4 Replies

6. Shell Programming and Scripting

How to Removing a dot from a file name?

I need a script that will allow me to rename all of my files in subdir /FilesIn as follows: From kumc_835_111200.RMT.dat to kumc_835_111200RMT.dat kumc_835_111200.KMR.dat to kumc_835_111200KMR.dat .................etc How do I do that whithout doing a sed ... (10 Replies)
Discussion started by: mrn6430
10 Replies

7. Shell Programming and Scripting

removing a word in a multiple file starting at the dot extension

hi I would like to ask if someone knows a command or a script on how to rename a multiple file in the directory starting at the end of the filename or at the .extension( i would like to remove the last 11 character before the extension) for example Below is the result of my command ls inside... (5 Replies)
Discussion started by: jao_madn
5 Replies

8. Shell Programming and Scripting

Perl removing strings from a variable value

Dear all, I have a variable called $abc, which the value is something like below, *** *********** : ***** where * can be anything. I need to remove all but the final characters until last whitespace. example grd groupstudy : tutor6/7 becomes tutor6/7 something like if... (2 Replies)
Discussion started by: tententen
2 Replies

9. Shell Programming and Scripting

Removing leading and trailing spaces only in PERL

Hi All, I have a file with the following contents with multiple lines 172445957| 000005911|8| 400 Peninsula Ave.#1551 | And,K |935172445957|000005911 607573888 |000098536 | 2|Ane, B |J |Ane |1868 |19861206|20090106|20071001 I want to trim the "leading and trailing spaces only" from... (2 Replies)
Discussion started by: kumar04
2 Replies

10. Shell Programming and Scripting

splitting on dot in perl

I am trying to split input that looks like ,2005-09-12 01:45:00.000000,2005-09-12 01:48:18.000000, I want to split on the dot . What I am using is ($ev_time,$rol)=split(/\./),$inputfile; This does not recognize the dot as what I want to split on. (2 Replies)
Discussion started by: reggiej
2 Replies

Featured Tech Videos