perl dot escaping issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl dot escaping issue
# 1  
Old 09-10-2012
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:

Code:
> echo -n "hello:world" | perl -F/:/ -ane 'print "$F[1]\n"'
>world

As expected I get the good result, but by typing:

Code:
> echo -n "hello.world" | perl -F/./ -ane 'print "$F[1]\n"'
> (nothing)

I get an empty line. I tried by escaping the dot by using :

Code:
> echo -n "hello.world" | perl -F/\./ -ane 'print "$F[1]\n"'
> (nothing)

but I get always the same result. It looks like an escaping problem. Do you have any tip?

Thanks in advance


Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by zaxxon; 09-10-2012 at 10:42 AM.. Reason: code tags
# 2  
Old 09-10-2012
try this..Smilie

Code:
echo -n "hello.world" | perl -F/[.]/ -ane 'print "$F[1]\n"'

# 3  
Old 09-10-2012
Cool thanks! it works
# 4  
Old 09-10-2012
A more common usage is:
Code:
echo -n "hello.world" | perl -F'\.' -ane 'print "$F[1]\n"'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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 03.04.14.000000 PM filename1| 06-Dec-11 05.05.14.000000 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

2. Shell Programming and Scripting

perl regex issue

Hi, I find it really strange while writing a simple regex to match and print the matched string, dibyajyo@fwtest:~ #perl -e '$x = "root@rashmi>"; print "matched string:$1\n" if ($x =~ /(root@rashmi)/);' matched string:root dibyajyo@fwtest:~ #perl -e '$x = "root@rashmi>"; print... (1 Reply)
Discussion started by: rrd1986
1 Replies

3. Shell Programming and Scripting

GREP Issue in Perl

Im storing multiple functions in a varaible called $check... The variable check contains the following: a() b() c() ... ..etc now im checking individually which function is kept in which file using GREP if ( grep \$check \i, <FILE> ) The problem is im getting the output for the... (1 Reply)
Discussion started by: rajkrishna89
1 Replies

4. Programming

perl socket issue

Hi I am teaching myself perl and am writing a socket application to get experience. I am using Eclipse with the EPIC plugin to run the code in debug mode. I think that sometimes the script is not releasing the port if I terminate it in debug mode as I am occasionally getting the message: - ... (3 Replies)
Discussion started by: steadyonabix
3 Replies

5. Shell Programming and Scripting

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 Anushree (2 Replies)
Discussion started by: anushree.a
2 Replies

6. Shell Programming and Scripting

Perl issue - please help!

Hello. I've been writing some code in Perl to read in strings from html files and have been having issues. In the html file, each "paragraph" is a certain file on the website. I need to find every one of the files that is a certain type, in this case, having green color....therefore... (7 Replies)
Discussion started by: akreibich07
7 Replies

7. UNIX for Advanced & Expert Users

Escaping special character stored in variables : perl

Hi just for regular use i m working on small module written in perl for getting date in specified format like i have to specify date format and then seperator to seperate date i am 95% done. now i m sure explanation i gave is not good enough so i am putting output here : C:\Documents and... (2 Replies)
Discussion started by: zedex
2 Replies

8. Shell Programming and Scripting

Perl Issue

Hi, I got this script from the web, this generates an LDAP report in CSV format. #!/usr/bin/perl # # Copyright (c) 2004 # Ali Onur Cinar &060;cinar&064;zdo.com&062; # # License: # # Permission to use, copy, modify, and distribute this software and its # documentation for... (23 Replies)
Discussion started by: raj001
23 Replies

9. Shell Programming and Scripting

perl issue ..

hi one perl issue i have xml file with 2 values and one condition b.w them <rule> <val1>12</val1> <cond>and</cond> <val2>13</val2> </rule> i read these values in hash in perl code $one{val1} = 12 $one{cond} = and $one{val2} = 13 now i want to form... (3 Replies)
Discussion started by: zedex
3 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
Login or Register to Ask a Question