in reply to Ugly variable-length record handling

Melly,
Salutations from vacation land. This could be way off base so forgive me. Assuming that individual records are not that large (just the file), then a user controlled buffer should work fine.
#!/usr/bin/perl use strict; use warnings; my $file = $ARGV[0] || 'export.dat'; open(my $fh, '<', $file) or die "Unable to open '$file' for reading: $ +!"; my @buffer; while (<$fh>) { if (/^1(\d+.*)/) { # Start of new record output_data(@buffer) if @buffer; # process last record if not + first @buffer = $1; # put new line in buffer } else { push @buffer, $_; # Add line to buffer } } output_data(@buffer) if @buffer; # Process last record if pre +sent sub output_data {}
I am sure you will have to tweak it. Update: I just realized writing to a temporary file was important. Oh well.

Cheers - L~R