473,382 Members | 1,563 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,382 software developers and data experts.

parsing

2
hi all, i'm new to perl so any help would be much appreciated. i need to sort out this few lines(shown below) from a text file and then write to a new text file. i'm pretty confused with the regex.

; Total registers ; 0 ;
; Total pins ; 2 / 635 ( < 1 % ) ;
; Total virtual pins ; 0 ;
; Total block memory bits ; 0 / 6,617,088 ( 0 % ) ;
; DSP block 18-bit elements ; 0 / 384 ( 0 % ) ;
; Total Receiver Channels ; 0 / 8 ( 0 % ) ;
; Total ransmitter Channels ; 0 / 8 ( 0 % ) ;
; Total PLLs ; 0 / 3 ( 0 % ) ;

here's what i've tried:
Expand|Select|Wrap|Line Numbers
  1. open(INFILE, 'd:\test.fit.rpt') or die 'error';
  2. open(OUTFILE, ">output.txt") or die 'error';
  3.  
  4. while($line = <INFILE>)
  5. {
  6. chomp($line);
  7.  
  8. if ($line =~ m/[^\s]\s(\w+)[^\s]\s(\d)\s[^\s]\s(\d+)\s[^\s](\d)[^\s+]/)
  9. {
  10. print OUTFILE "$line\n";
  11. }
  12.  
  13. }
  14.  
  15. close (INFILE);
  16. Close (OUTFILE);
  17.  
Sep 25 '08 #1
4 1214
KevinADC
4,059 Expert 2GB
You need to let us know what you are trying to parse out of the lines of text you posted. Then someone can help you with suggestions or code.
Sep 25 '08 #2
tozi
2
what i need is to extract out only a few lines(which is shown as above) from a text file.
Sep 25 '08 #3
Icecrack
174 Expert 100+
you should fix up line 12 of the code above

Expand|Select|Wrap|Line Numbers
  1. Close (OUTFILE);
should be


Expand|Select|Wrap|Line Numbers
  1. close (OUTFILE);
lowercase your Perl commands.
don't forget Perl is strict.
Sep 26 '08 #4
Ganon11
3,652 Expert 2GB
In fact, make it stricter by always adding:

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
to the top of your scripts.
Sep 26 '08 #5

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

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
0
by: Pentti | last post by:
Can anyone help to understand why re-parsing occurs on a remote database (using database links), even though we are using a prepared statement on the local database: Scenario: ======== We...
9
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics"...
5
by: randy | last post by:
Can some point me to a good example of parsing XML using C# 2.0? Thanks
3
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
7
by: Daniel Fetchinson | last post by:
Many times a more user friendly date format is convenient than the pure date and time. For example for a date that is yesterday I would like to see "yesterday" instead of the date itself. And for...
1
by: eyeore | last post by:
Hello everyone my String reverse code works but my professor wants me to use pop top push or Stack code and parsing code could you please teach me how to make this code work with pop top push or...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.