CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
spliting array into records with a word-delimiter

 



yaniv_av
Novice

Oct 29, 2002, 10:47 AM

Post #1 of 2 (431 views)
spliting array into records with a word-delimiter Can't Post

I need to split a text file into records (sub strings) when the delimiter is a word.
I can'y use the split function because it takes 1 character as the delimiter.
example:
the text file:
--------------
<BODY>
kjh kjh kjh
</BODY>
<BODY>
sadlk salkd asop
</BODY>
--------------
I want to split it to 2 strings with the delimiter </BODY>:
string 1) <BODY> kjh kjh kjh kjh
string 2) <BODY> sadlk salkd asop

how cat I do it as shortly as I can ?


thodi
stranger

Oct 29, 2002, 11:00 AM

Post #2 of 2 (430 views)
Re: [yaniv_av] spliting array into records with a word-delimiter [In reply to] Can't Post

Funny, my perldoc tells me that split uses a pattern and not a single character.

Code
my @bodies = split /<\/BODY>/, join '', <DATA>;



(This post was edited by thodi on Oct 29, 2002, 11:01 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives