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

Processing a portion of a file.

3
Hi ,

I want to grep for multiple lines, like

;START
;copy here
;END

I need to grep from ;START to ;END
I am using windiws XP.

Please let me know if anybody can help.

I tried
grep /^;START[.*][\n];END$/mi, <FILE>;


Thanks
Anil
Jul 30 '07 #1
3 978
miller
1,089 Expert 1GB
Take a look at the Range Operator on perldoc, and do your file processing using a while loop.

- Miller
Jul 30 '07 #2
KevinADC
4,059 Expert 2GB
you need to return the value of grep to an array:
Expand|Select|Wrap|Line Numbers
  1. my @lines = grep /^;START[.*][\n];END$/mi, <FILE>; 
[.*] is a character class of a dot and an asterisk, not the same as (.*) which captures the pattern in memory, and [\n] is not needed if this really is a multiline match.

try like this:

Expand|Select|Wrap|Line Numbers
  1. my @lines = grep /^;START(.*);END$/mi, <FILE>;
Jul 30 '07 #3
miller
1,089 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. my @lines = grep {/^;START/../^;END/} <DATA>;
  2.  
  3. print @lines;
  4.  
  5. __DATA__
  6. more stuff
  7. and yet
  8. ;START
  9. ;copy here
  10. ;END
  11. final stuff
  12. and yet
  13.  
- Miller
Jul 30 '07 #4

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

Similar topics

15
by: Anand Ganesh | last post by:
HI All, I have an Image. I want to clip a portion of it and copy to another image. How to do this? I know the bounding rectangle to clip. Any suggestions please. Thanks for your time and...
0
by: Ganapathy | last post by:
I have COM dll code written in VC 6.0. When i tried compiling this code in VC 7, The MIDL cmpiler gets called twice. i.e. it initially compiles fully & immediately a line - 64 bit processing'...
11
by: Mark Rae | last post by:
Hi, Is there any way to modify the style of the button portion of an HtmlInput control? I have a CSS class which I use for all of the buttons to try to make them a little less ugly than the...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
5
by: Geoff Pennington | last post by:
My VB.Net app reads an Excel file, processes it one row at a time, and when processing is complete writes the row to a database. The typical file will have several thousand rows and may take a...
4
by: News | last post by:
Hi Everyone, The attached code creates client connections to websphere queue managers and then processes an inquiry against them. The program functions when it gets options from the command...
4
by: larre | last post by:
Hi guys, i have a flat file, that i would like to populate into a database. The problem is that the file format is not standard, each record differs from the other depending on the fields available....
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...
8
by: Chilly8 | last post by:
How to I change the HTML portiion of a PHP script? I want to modify the HTML portion of phpBB, and the code in there to have StatCounter record hits to that part of my web site. I already have the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: 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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.