Perl Newbie trying to parse file 
Author Message
 Perl Newbie trying to parse file

Hello:

I have a bunch of files that need to be parsed and updated to a mysql
database.

Could someone please help me with parsing this file or provide ideas:

Value1:    Data
Value2:    Data
                Data
                Data

Value3: Data
Value4: Data
              Data

Now how do I handle if data has got new lines embedded.

Please help!!!!

Thanks
Please post to the newsgroup.

sr



Wed, 18 Jun 1902 08:00:00 GMT  
 Perl Newbie trying to parse file
SR wrote ..

Quote:
>I have a bunch of files that need to be parsed and updated to a mysql
>database.

>Could someone please help me with parsing this file or provide ideas:

>Value1:    Data
>Value2:    Data
>                Data
>                Data

>Value3: Data
>Value4: Data
>              Data

>Now how do I handle if data has got new lines embedded.

the simplest solution .. assuming that the file is of a reasonable size

1. slurp the entire file into a scalar

2. use a global regex to get your values out

the more complex solution .. which will work well irrespective of file
size

1. iterate over each line in the file using the '..' or '...' operator
to determine where a record begins and ends

--



Mon, 03 Feb 2003 08:43:01 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. newbie trying to parse one file into three

2. Newbie trying to parse CGI POST data

3. Trying to parse a file...need help

4. Newbie trying to do a file move

5. newbie trying to solve file copying problem

6. Newbie trying to compare two .txt files

7. Wanted File parsing example and a newbie question...

8. newbie...To parse or not to parse

9. Newbie - parsing text files

10. NEWBIE: PARSE ASCII FILE

11. Newbie wants to parse a binary file

12. Newbie parsing file with spaces Q

 

 
Powered by phpBB® Forum Software