foreach $x (&str2patt($ARGV[0])) {
  print "$x ";
  }
print "\n";

################################################################
# Subroutine str2patt                                          #
#   Input:  a string                                           #
#   Output: a list consisting of the associated numerical      #
#           pattern                                            #
################################################################
sub str2patt {
  local(@mypattern);               # Output list
  local($n);                       # Actual number in pattern
  local(%myassoc);                 # Character is key,
                                   #   associated number ist value.

  foreach (split(//,$_[0])) {      # Split input string into single chars.
                                   # Actual character in $_
    if ($myassoc{$_}) {            # Character already registered
      push (@mypattern,$myassoc{$_}); # Append associated number.
      }
    else {
      $myassoc{$_} = ++$n;         # Increment actual number and
                                   #   associate character with it.
      push (@mypattern,$n);        # Append actual number.
      }
    }
  return @mypattern;
  } #--- str2patt ----------------------------------------------
