my $start = q{AA}; my $next = q{AB}; my $count = 0; my $value; foreach my $entry ( @{$strings} ) { if ( $count == $#$strings ) { $next = q{$}; } else { $next = q{\,\ } . _alpha_add($start); } $affiliation_string =~ m/$start\((.*?)\)($next)/s; $value = $1; $affiliation_key->{$entry} = $value; $start = _alpha_add($start); $next = _alpha_add($next); $count++; } #### sub _alpha_add { my $string = shift; if ( substr( $string, 1, 1 ) eq q{Z} ) { my $first_character = substr( $string, 0, 1 ); my $second_character = substr( $string, 1, 1 ); $first_character++; $second_character = q{A}; $string = $first_character . $second_character; } else { $string++; } return $string; }