Changeset 3195


Ignore:
Timestamp:
2002-06-26T09:55:21+12:00 (22 years ago)
Author:
kjdon
Message:

create_shortname (turns a long metadata name into 2 char name) changed to ignore non-letdigs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/mgppbuildproc.pm

    r3148 r3195  
    645645}
    646646
     647#chooses the first two letters or digits for the shortname
     648#now ignores non-letdig characters
    647649sub create_shortname {
    648650    $self = shift(@_);
     
    650652    my ($realname) = @_;
    651653    #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    }
    653662    $shortname =~ tr/a-z/A-Z/;
    654663
    655     #if already used, take the first and third letters and so on
     664    #if already used, take the first and third letdigs and so on
    656665    $count = 1;
    657666    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/;
    662671   
    663672    }
    664673    else {
    665         $realname =~ s/^.//;
     674        #remove up to and incl the first letdig
     675        $realname =~ s/^[^\w]*\w//;
    666676        $count = 0;
    667677    }
Note: See TracChangeset for help on using the changeset viewer.