Changeset 3195
- Timestamp:
- 2002-06-26T09:55:21+12:00 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/mgppbuildproc.pm
r3148 r3195 645 645 } 646 646 647 #chooses the first two letters or digits for the shortname 648 #now ignores non-letdig characters 647 649 sub create_shortname { 648 650 $self = shift(@_); … … 650 652 my ($realname) = @_; 651 653 #take the first two chars 652 my ($shortname) = $realname =~ /^(\w\w)/; 654 my $shortname; 655 if ($realname =~ /^[^\w]*(\w)[^\w]*(\w)/) { 656 $shortname = "$1$2"; 657 } else { 658 # there aren't two letdig's in the field - try arbitrary combinations 659 $realname = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 660 $shortname = "AB"; 661 } 653 662 $shortname =~ tr/a-z/A-Z/; 654 663 655 #if already used, take the first and third let ters and so on664 #if already used, take the first and third letdigs and so on 656 665 $count = 1; 657 666 while (defined $self->{'indexfieldmap'}->{$shortname}) { 658 if ($realname =~ /^ (\w).{$count}(\w)/) {659 $shortname = "$1$ 2";660 $count++;661 $shortname =~ tr/a-z/A-Z/;667 if ($realname =~ /^[^\w]*(\w)([^\w]*\w){$count}[^\w]*(\w)/) { 668 $shortname = "$1$3"; 669 $count++; 670 $shortname =~ tr/a-z/A-Z/; 662 671 663 672 } 664 673 else { 665 $realname =~ s/^.//; 674 #remove up to and incl the first letdig 675 $realname =~ s/^[^\w]*\w//; 666 676 $count = 0; 667 677 }
Note:
See TracChangeset
for help on using the changeset viewer.