in reply to Read files and convert extracted text to .csvc

Are you saying that those lines of "######" are actually in the text files? If so, then the previous reply about setting the special "$/" variable will help you a lot. Or, if the actual text files use some other consistent pattern as the separator between 3-line records like the one you showed, just set $/ to that other pattern (look at the perlvar manual for more information about $/).

If the files are just sequences of 3-line records with nothing else separating the sets, you'll need something like:

my %record; my ( $id, $field ); while (<>) { chomp; if ( /^RECORD:\s+(\d+)/ ) { $id = $1; elsif ( /Field:\s/ ) { $field = $_; elsif ( /MSG#\s ) { $record{$id}{field} = $field; $record{$id}{msg} = $_; } } # now go through the %record set, output to csv...

As for putting stuff into a csv file, Text::CSV will be a big help, and as indicated above, you can install your own copy of the module in your home directory. But maybe your unix system already has it -- try "perldoc Text::CSV" as a shell command, to see if the module there.

(And most unix systems that support multiple users have at least one "sysadmin" person, who will often accept reasonable requests for installing non-core perl modules from CPAN. You do know how to contact your sysadmin, right?)

Replies are listed 'Best First'.
Re^2: Read files and convert extracted text to .csvc
by AnomalousMonk (Archbishop) on May 22, 2010 at 18:33 UTC
    ... if the actual text files use some other consistent pattern as the separator between 3-line records like the one you showed, just set $/ to that other pattern ... [Emphases added.]

    It's important to remember that $/ does not detect record separators based on a pattern (i.e., a regular expressison) match, but on an exact string match. See discussion in perlvar.