sub smut_filter
{
 # Get the data we want to filter the smut words from:
 my ($wordlist) = shift;
 
 # Declare our variables as local to this subroutine:
 my (@smut,@letters,$num,$replace);
 
 # No smutfile was defined, return the data unchanged:
 if (!$smutfile){return $wordlist;}
 
 # Get the list of smut words from the smutfile.
 @smut = getfile($smutfile,0); 
 
 
	# Now we replace any smut words in a very clever fashion.
	# We leave the first and last letters of the word intact, and preserve the length.
	# Example: "frig" becomes "f**g" and "fruitloop" becomes "f*******p".
 
	# This is done as follows:
 
	# 1. Loop over each word in the array of smut words as follows:
	
	# 	a. Remove any new lines from the word (using 'chomp').
	# 	b. Split the word into an array of letters (@letters).
	# 	c. Get the number of letters, minus two and store in $num.
	# 	d. Copy the first letter of the word to $replace.
	# 	e. Append "*" to $replace, up to the second last letter of the word.
	# 	f. Append the last letter of the word to $replace.
	# 	g. We should now have something like "f**g" which would replace "frig".
	# 	h. Replace all occurances of the smutword with the clean version above.
 
	# 2. Return the data with all the smut words filtered out.
 
 foreach my $smutword (@smut){
  chomp($smutword);
  @letters = split(//,$smutword);
  $num = $#letters - 2;
  $replace = $letters[0];
  for (0..$num){$replace .= "*";}
  $replace .= $letters[-1];
  $wordlist =~ s!$smutword!$replace!gi;
 }
return $wordlist;
}
1;