A 5##### 8 Z Axxxx xxxx, ANN 19793.43 02/02/2012 06/08/2012 32989.05 B 03###### S JOxxx xxxx, ADxxx .00 xx/xx/xxxx 0 C 0 7 14## D xxxx ST #101 .00 02/08/2012 06/15/2012 NOV D 0 U MILWAUKEE, WI ##### 32989.05 02/08/2012 3 E 3##### MILWAUKEE WI .00 53214 12 F acctnum=508####8 A 50#### 8 Z ALLEN ,Nxxxxx 75.00 05/27/2012 06/05/2012 1845.00 B 037###### E Nxxxx ALLEN .00 09/xx/xxx 06/05/2012 MYT####### C 734####### S 15659 XXXX xxxxx .00 06/06/2012 06/14/2012 MYT9##### NOV D 0 C TAYLOR,MI ##### 1845.00 05/27/2012 3 3 E 37##### S TAYLOR MI .00 48180 3 12 F acctnum=50##### A 50##### 9 Z Axxxx xxxxxx ,SUSETH 75.00 05/05/2012 05/15/2012 2045.00 B 0000000000 E SUSE xxxxxxx RIxxx .00 03/18/xxxx 05/15/2012 AJT9###### C 313###### 440 xxx xxxx .00 05/16/2012 06/15/2012 AJT9#2###### NOV D 0 C LINCOLN PARK,XX xx### 2045.00 05/05/2012 1 3 E 0 S LINCOLN PARK XX .00 48146 1 12 F acctnum=50##### #### 0 S LINCOLN PARK MI .00 48146 1 12 #### use strict; use warnings; my $vers = q|1.5|; my $letter = 'A'; #my $file = qq(/var/adm/scripts/20121106_C1SA_174204.tmp); my $file = qq(/var/adm/scripts/tstin); my ($acctnum,@acctnum); open (my $f, "+<", $file) or die $!; while (my $ln = (<$f>)) { #next if ($. == 1..88); next if $ln !~ /\s\s\s\s\d+.*/; next if $ln =~ /\A\w+|\cM\s\d+\.\d+.*/; substr($ln, 1,2) = ""; substr($ln, 0,1) = $letter++; if ( $. % 5 == 1 ) { ###-- every 5th line --### if ( substr($ln, 10, 4) =~ /\s+/ ) { substr($ln, 10, 4, ""); $acctnum = substr($ln, 2, 10); push @acctnum, "F acctnum=$acctnum"; } } ###-- 79/80 are the 2 spaces not needed --### if ( length(substr($ln, 79, 2)) > 1 || substr($ln, 79, 2) =~ /\s*/ ) { substr($ln, 79, 2, ""); print $ln; } else { next; } }