CONFIG_FILE="$DEPENDS_CONFIG/perl_config.sh" &&

if [[ -f $CONFIG_FILE ]]; then
  if [[ $(installed_version perl) != $VERSION ]]; then
     message "${MESSAGE_COLOR}Config changes between versions, using old config is not an option. Removing $CONFIG_FILE${DEFAULT_COLOR}" &&
     local OLD_CUSTOM="n" &&
     rm -f "$CONFIG_FILE"
  else
    config_query OLD_CUSTOM "Use old custom configuration for Perl?" y

    if [[ $OLD_CUSTOM == n ]]; then
       config_query RM_OLD_CUSTOM "Remove old custom configuration file ?" n
    fi &&

    if [[ $RM_OLD_CUSTOM == y ]]; then 
       rm -f "$CONFIG_FILE"
    fi
  fi
else
  # Just used for the check below
  local OLD_CUSTOM="n"
fi &&

if  [[ $OLD_CUSTOM  ==  n ]]; then
  config_query NEW_CUSTOM "New custom configuration for Perl?" n
else
  # if OLD_CUSTOM==y, NEW_CUSTOM (a stored one) shall not get in the way!
  NEW_CUSTOM=n
fi &&

persistent_add THREADED &&
config_query THREADED "Compile threaded perl?" n

if ! declare -f up_trigger > /dev/null; then
# only do this hack on sorcery < 1.13
PREVIOUS_VERSION="`installed_version perl`"
CURRENT_VERSION=$VERSION
unset REBUILD_ALL

if  [ -n "$PREVIOUS_VERSION"  -a  "$PREVIOUS_VERSION" != "$CURRENT_VERSION" ]; then
    cat  <<- ____EOM

	I see you've got a $PREVIOUS_VERSION perl library. This probably
	means that you're upgrading perl.

	If this is not the case you can skip the next paragraph
	and just answer no to the question...

	   Perl 5.8 is binary incompatible with previous versions
	   this means that you'll have to rebuild all installed 
	   perl spell's. I can do that for you.

	   After all spells have successfully been build you'll have to
	   remember to _MANUALLY_ remove the following directories:
	   
	      rm -rf ${INSTALL_ROOT}/usr/lib/perl5/$PREVIOUS_VERSION
	      rm -rf ${INSTALL_ROOT}/usr/lib/perl5/site_perl/$PREVIOUS_VERSION

____EOM
	config_query REBUILD_ALL "Do you want me to rebuild all perl spells?" n
fi
fi
