PERL \c char
Hi guys, I am stuck up in a situation. I have a SUN box with certain logs which I need to parse to draw a report using Perl.
Now, when I load the text file using a perl degugger to see how the text looks like when the first line of the log file is read in a variable. below is the snapshot of first line read from the file. My usefull values are like ITS=20100620082137,409 cIOTS=20100620082137,691. It seems \c is the character which could be used as value seperator. Code:
"ITS=20100620082137,409\cIOTS=20100620082137,691\cIUSER=untrustedapp\cIOP=GetSubscriptionStatus\cIRC=1000\cIMSISDN=966501237533\cISID=61\cIDATA_CLI={SUBSCRIPTIONTYPE=10}\cIDATA_RES=\cI\cI" So, I tried to split the values using the split function but Its not working. Any idea about this "\c" char and how can I manage to split the text in my text file. Code:
@values = split('\c', $item); Code:
ITS=20100620102817,341 OTS=20100620102817,603 USER=untrustedapp OP=GetSubscriptionStatus RC=1000 MSISDN=966535468329 |
The character you see is not \c but the control character \cI so maybe you can split("\cI", ...).
|
Quote:
First find our the ASCII code of what is seen as '\c' - use 'ord' function for that: perldoc -f ord ; you'll probably need 'substr' too: perldoc -f substr . When you're done with that, it will be pretty obvious how to write 'split'. |
Hi, maxmeier12 Thx buddy. Ur idea worked. I replaced /c with /cI and it worked ...
|
\cI = ctrl-I is a TAB.
also, if you use single quotes in perl it won't substitute value "\n" is a newline '\n' is literally two characters '\' and 'n' try split "\cI" or better, split "\t" |
All times are GMT -5. The time now is 07:00 PM. |