- my ($link, $lastchar) = $links[$i + 1]->[0] =~ /(.*)(.)/;
- $link .= $lastchar le 'a' ? '.' : chr( ord($lastchar) - 1 );
- next if $link eq $links[$i]->[0] and $i;
- $links[$i]->[1] = $link;
+ # end at start of next value with the last character decremented
+ my $next = $links[$i + 1];
+ $next =~ s{(.)$}{ $1 le 'a' ? '.' : chr( ord($1) - 1 ) }e;
+ # amend range if it's ahead
+ $links[$i] .= '-'.$next unless $next eq $links[$i];