samuelt has asked for the wisdom of the Perl Monks concerning the following question:

I need help rather urgently... I have a file that looks like this but has much more of last 2 lines (between 20 and 80 lines per "group" and repeats like 80 times (see below...) and want it splitted and formatted with 1 tab between each part (but there are names that should be preserved tho..)
GREN: 1 200m FRISIM HERRAR SENIORER PASS 1 10.00 REKORD: V€RLDS EUROPA NORDISKT SVENSKT SENIOR: 1:44.06 1:44.89 1:46.76 1:46.76 JUNIOR: 1:50.70 NR IDNR NAMN F…DD KOD F…RENING ANM.TID 1. 277 Jonas Persson 83 2504 MKK 1:48.26 2. 585 Petter Stymne 83 0297 SK NEPTUN 1:48.32 3. 583 Peter Edvardsson 81 3500 SK NEPTUN 1:48.46
I't would be nice to extract "GREN: 1 ..." to file name (but not a necissity(<- thats just plain wrong :P ) ) and the repeating part in the files... should say that there a fields that might be empty also... Can any one give me a hint?
--- Gosh darn...

Replies are listed 'Best First'.
Re: splitting and formatting my biig textfile...
by particle (Vicar) on Jun 17, 2003 at 17:36 UTC

    there is hope. if there is a record separator, like \nGREN:, you can set the magical $/ to that, and separate the records. perhaps that's a good start.

    { local $/= "\nGREN:"; while(<DATA>) { ## ...more here } }

    ~Particle *accelerates*

Re: splitting and formatting my big textfile...
by dws (Chancellor) on Jun 17, 2003 at 17:56 UTC
    I have a file ... and want it splitted and formatted with 1 tab between each part ...

    I'm not clear on what a "part" is in your context. Could you provide an example of how you would like the result to look?