use strict; use warnings; use List::MoreUtils qw/natatime/; my $it = natatime 5, ; while ( my @lines = $it->() ) { my $letter = 'A'; my $acctNum = do { $lines[0] =~ /\s+(\d+)\s+(\d+)/; $1 . $2 }; push @lines, " acctnum=$acctNum"; print for map { s/\s+/$letter++ . ' '/er } @lines; print "\n"; } __DATA__ 50###### 8 Z Axxx ,xxxxxxx 19793.43 02/02/2012 06/08/2012 32989.05 037###### S JOYCE xxxxxxS .00 06/06/xxxx 0 0 7 1471 xxxx xxxx x #101 .00 02/08/2012 06/15/2012 NOV 0 U MILWAUKEE, WI xxxxx 32989.05 02/08/2012 3 3##### MILWAUKEE WI .00 53214 12 50##### 8 Z Axxx ,Nxxxxx 75.00 05/27/2012 06/05/2012 1845.00 03######3 E Nxxxx Axxxx .00 09/xx/xxxx 06/05/2012 MYT##### 7####### S 156xxx xxxxx BLVD .00 06/06/2012 06/14/2012 MYT######## NOV 0 C TAYLOR,MI 48180 1845.00 05/27/2012 3 3 37###### S TAYLOR MI .00 48180 3 12 50##### 9 Z ALxxxx Rxxxx ,SUSxxx 75.00 05/05/2012 05/15/2012 2045.00 0000000000 E SUSE Axxxxx Rxxxx .00 03/xx/xxxx 05/15/2012 AJT9####### 31####### 44xxx xxx AVE .00 05/16/2012 06/15/2012 AJT92###### NOV 0 C LINCOLN PARK,MI xxxxx 2045.00 05/05/2012 1 3 0 S LINCOLN PARK MI .00 48146 1 12