in reply to Ugly variable-length record handling
I am sure you will have to tweak it. Update: I just realized writing to a temporary file was important. Oh well.#!/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 {}
Cheers - L~R
|
|---|