my %layout = (file1 => 0, file2 => 0, ... file8 => 20, file9 ->10, file10 => 11); #note that Perl starts counting at zero, so 1 had to be subtracted from the starting positions. # now, for each file, you could yank the acct number out like this: $acct = substr($line, $layout{$file_name}, 9); # where $file_name corresponds to file1, file2, etc, in %layout as appropriat