in reply to parsing a file

I am rather late to this party but assuming your records are all seperated by a single blank line and there are no superfluous blank lines then this rather obfu looking one liner will get you there

perl -pe'BEGIN{print"__BEGIN__\n"}s/^\s*$/__BEGIN__\n__END__\n/;END{pr +int"__END__\n"}' <file>

Or the mildly shorter but fiercly uglier

perl -pe'$e="__END__\n";BEGIN{$b="__BEGIN__\n";print$b}s/^\s*$/$b$e/;E +ND{print$e}' <file>

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

Replies are listed 'Best First'.
Re^2: parsing a file
by Limbic~Region (Chancellor) on Jan 25, 2005 at 18:21 UTC
    Random_Walk,
    I believe in addition to adding the __BEGIN__/__END__ tags, tcf03 also wanted to "process" each user's information. The trouble I had was in figuring out what was meant by "process", so I just added a sub that could be changed according to suite one's needs.

    Cheers - L~R