Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing a Regular Expression in Perl

Status
Not open for further replies.

Sparkle1984

Programmer
Nov 26, 2003
3
GB
I am writing a Perl program which reads in text file made up of records of data about different companies (clients). Each individual record in the file starts with a token (= and ends with =). I need to write a regular expression pattern which will split the text file into individual records, by locating all the brackets and equals signs.

I have tried using the following code:
@records = ($records = ~M/(\(= .*? =\))/xg;
but this causes an error.

Thanks for any help.
 
Hello Sparkle,

Could you post a couple of lines of the text file please?

Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Yes, here's one example record from the text file:

(= CLIENT-name: [ MegaFizz-Inc]
YEAR:1993; Month:april;
value:[$388 ]
area:[ C.I.]
discount:[8%]
=)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top