Mavericks suggestion to set the input record separator to 0x0c will allow you to read in one record at a time and avoid all that mucking around with single characters. It will no doubt speed your code considerably as well as simplifying it quite a lot. Let Perl work for you.
Here is a small optimisation of your last two subs that will save a bit of time too. By using the 'x' operator rather than a while loop we add our whitespace pad in one operation. By using a regex to stip leading and trailing whitespace we save a lot of mucking about and let the regex engine do the work. This too will be much faster.
# Pad out with trailing whitespace as necessary sub pad { my ($data, $len) = @_; my $pad = $len - (length $data); $data .= " " x $pad unless $pad < 0; return $data; } # Get rid of leading/trailing whitespace sub normalise { my $value = shift; $value = s/^\s+|\s+$//gm; return $value; }
Hope this helps
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In reply to Re: Perl scripts slowing down towards end of file processing
by tachyon
in thread Perl scripts slowing down towards end of file processing
by JPaul
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |