  ...
  my $newdir = shift;
  if ($newdir =~ m{^/}) {
    $dir = $newdir;                  # Absolute path 
  } else {
    $dir = _fixpath("$dir/$newdir"); # Relative path
  }
  if (! -e "$FILE_ROOT/$dir") {      # $dir does not exist
    $newdir = file_guess($kernel, $who, $newdir, 
                               "Directory $newdir does not exist",
                              );
    return unless defined $newdir;
    if ($newdir =~ m{^/}) {
      $dir = $newdir;                  # Absolute path 
    } else {
      $dir = _fixpath("$dir/$newdir"); # Relative path
    }
  }
  ...


I want to eliminate the repated if-else block and to make the code as
tidy as possible.  

file_guess gets the directory name and searches in the current
directory for items with names like $dir.  If it finds exactly one
match, it returns it.  Otherwise, it issues the message "Directory
$newdir does not exist" and returns undef.  It is permissible to
rewrite file_guess to give it a more convenient behavior.


----------------------------------------------------------------

It now looks like:


  ...
  my $newdir = shift;
  my $dir = _append_path(..., $newdir);
  if (! -e "$FILE_ROOT/$dir") {      # $dir does not exist
    $newdir = file_guess($kernel, $who, $newdir, 
                               "Directory $newdir does not exist",
                              );
    return unless defined $newdir;
    $dir = _append_path(..., $newdir);
  }
  ...

