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: Intermediate:
help to read blocks of data in text files...

 



abelsgmx
Novice

Jul 18, 2002, 9:36 AM

Post #1 of 3 (1819 views)
help to read blocks of data in text files... Can't Post

Hi, anyone know how to read text blocks separated by one | caracter, sample:

Charles Harmstrong
Smith Cornell
|
Katherine Jhones
Laura Branigan
Ann Bush
|
Fidel Castro Dummy
|
my problem is when i try to read the names by blocks and put in a variable, thanks a lot!!
Unsure


uri
Thaumaturge

Jul 18, 2002, 9:09 PM

Post #2 of 3 (1813 views)
Re: [abelsgmx] help to read blocks of data in text files... [In reply to] Can't Post


Code
$/ = '|' ; 

while( <> ) {
blah blah
}

that sets the input record separater to '|'. if you are reading multiple files do that assignment in a local inside a block so it will get reset when the block is exited. that block could be a sub as well.


Code
sub read_records { 

local( $/ ) = '|' ;

while( <> ) {

blah
}
}


abelsgmx
Novice

Jul 23, 2002, 5:32 PM

Post #3 of 3 (1799 views)
Re: [uri] help to read blocks of data in text files... [In reply to] Can't Post

Thanks a lot for your help!!!

Smile

 
 


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

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