in reply to parsing a file

Limbic`s code is well written, but i take a different approach.
Assumptions:
a) USER, LOGIN and MORE is a kind of markup.
b) You want to process the data somehow before writing it back.
c) You are capable to write file in/output by yourself.

That leads to the following code:
#!/usr/bin/perl use strict; use warnings; { local $/ = ""; # paragraph mode while ( <DATA> ) { chomp; print process_user($_); } } sub process_user { my ($user, $login, @info) = split ("\n", shift); $user =~ s/USER //; $login =~ s/LOGIN //; @info = map { s/^MORE //; $_ } @info; #sample processing: add a star everywhere return join "\n", "__BEGIN__", "USER *$user", "LOGIN *$login", (map { "MORE *$_" } @info), "__END__\n"; } __DATA__ USER 1 LOGIN date MORE info MORE info USER 2 LOGIN date MORE info MORE info
That produces this output:
__BEGIN__ USER *1 LOGIN *date MORE *info MORE *info __END__ __BEGIN__ USER *2 LOGIN *date MORE *info MORE *info __END__
Update:
Corrected minor typo and Limbic`s "s".

holli, regexed monk