473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

parse text with Perl - case study

Hello,

I am a newbie in perl and i have the following problem.
I have as input a text file in the following format:
================================================== ==============================
[DEBUG] 5/24/07 5:35:50 PM : Finished to read one line : r 250 1006 -63 -65 91 -6 -8 319*
[DEBUG] 5/24/07 5:35:50 PM : Successfully opened DB.
[DEBUG] 5/24/07 5:35:50 PM : Going to read one line.
[DEBUG] 5/24/07 5:35:50 PM : Going to close DB.
[DEBUG] 5/24/07 5:35:50 PM : Successfully closed DB.
[DEBUG] 5/24/07 5:35:50 PM : Going to open DB.
[DEBUG] 5/24/07 5:35:50 PM : Finished to read one line : r 250 1015 -52 -72 91 -6 -8 319*
[DEBUG] 5/24/07 5:35:50 PM : Going to read one line.
[INFO] 5/24/07 5:35:50 PM : Call RaceField constructor.
[INFO] 5/24/07 5:35:50 PM : Opponent has no record of today.
[DEBUG] 5/24/07 5:35:50 PM : Finished to read one line : r 250 1019 -61 -83 92 -7 -8 319*
[DEBUG] 5/24/07 5:35:50 PM : Going to read one line.
[DEBUG] 5/24/07 5:35:50 PM : Going to close DB.
================================================== ===========================

I would like to parse this text file and extract in a new text file the following :

r 250 1006 -63 -65 91 -6 -8 319*
r 250 1015 -52 -72 91 -6 -8 319*
r 250 1019 -61 -83 92 -7 -8 319*

I do not know how to recognize the characters "r.....*" from each line.

please if you can help me

thank you
kk
Jun 11 '07 #1
2 2125
KevinADC
4,059 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. if (/: (r\s+[\d -]+\*)/ ) {
  2.   print $1;
  3. }
beginning perl
Jun 11 '07 #2
miller
1,089 Expert 1GB
A slightly cleaner regex would be:

Expand|Select|Wrap|Line Numbers
  1. if (/Finished to read one line : (.*)/ ) {
  2.     print $1;
  3. }
  4.  
- Miller
Jun 12 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Xah Lee | last post by:
python has this nice unicodedata module that deals with unicode nicely. #-*- coding: utf-8 -*- # python from unicodedata import * # each unicode char has a unique name. # one can use the...
3
by: lonelyplanet999 | last post by:
Hi, I'm a newbie to perl and is now studying about perl programming, I read some perl programming tutorials online (enter 'Perl tutorial' at google.com) and also find some sample perl scripts...
9
by: Gary | last post by:
I need to read a table from MySQL into a Perl script (already working) and then be able to print fields from the table selectively using a print button which is part of the HTML/CGI. Can someone...
2
by: Vincent | last post by:
hi, can anyone help ? $text=qq(a11.CLEC_ID ACNA, count(1) PR402RSSSDEN, sum(Decode(a11.CMPINTV-a11.APPINTV,0,a11.COMP_MAC_DY_CNT,a11.LEAST_DELAY_DAYS)) PR402RSSSNUM,...
7
by: Sam Lowry | last post by:
Greetings. I am trying to do something which should elementary for Perl, but I have only been able to find bits and pieces on it. When I put the bits together they do not work. Maybe I am going...
385
by: Xah Lee | last post by:
Jargons of Info Tech industry (A Love of Jargons) Xah Lee, 2002 Feb People in the computing field like to spur the use of spurious jargons. The less educated they are, the more they like...
82
by: Edward Elliott | last post by:
This is just anecdotal, but I still find it interesting. Take it for what it's worth. I'm interested in hearing others' perspectives, just please don't turn this into a pissing contest. I'm in...
5
by: js | last post by:
I have a textbox contains text in the format of "yyyy/MM/dd hh:mm:ss". I need to parse the text using System.DateTime.Parse() function with custom format. I got an error using the following code. ...
1
by: Xah Lee | last post by:
Text Processing with Emacs Lisp Xah Lee, 2007-10-29 This page gives a outline of how to use emacs lisp to do text processing, using a specific real-world problem as example. If you don't know...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.