Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re^3: Perl Extract specific string

by CountZero (Bishop)
on Feb 09, 2013 at 16:54 UTC ( #1017975=note: print w/replies, xml ) Need Help??

in reply to Re^2: Perl Extract specific string
in thread Perl Extract specific string

Perl is such a powerful language, you only need a few lines of code:
use Modern::Perl; while (<DATA>) { my ( $date, $msisdn, $ud, $trxtime, $response ) = map { /:([^:]+)/ ? $1 : $_ } ( split /[\s+,]/ )[ 0, 6, 7, 8, 11 +]; say join ',', $date, $msisdn, $ud, substr( $trxtime, 0, 8 ), $resp +onse; } __DATA__ 06.02.2013 12.24.01:909 5807225321 INFO {EXT:httpadapter:17:14:}[0]RUL +EZ [HTTPADAPTER],msisdn:637584930382,ud:Pan,trxtime:20130206122401 Re +sponseDeltaTime:31 ms ResponseCode:200 ResponseBody:OK


A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1017975]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2016-10-24 16:34 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (309 votes). Check out past polls.