#!/afs/athena/contrib/perl/p


print("First string:  ");
$a = (<STDIN>);
chop($a);
print("Second string: ");
$b = (<STDIN>);
chop($b);
$res = (&fmatch($a, $b));
print("Match: $res\n");

sub fmatch {
local($A, $B) = @_;
local($l) = (length($A) < length($B)) ? length($A) : length($B);
local($m) = 0;
local($w) = 2;
local($k);
 
$A eq $B && return(1.0);
$l > $w || return(0.0);

for $k(0..$l-$w) { 
  local($s) = substr($A, $k, $w);
  #---escape r.e. characters in string A---
  print("\*, ") if ($B =~ $s);
  $s =~ s/([()[\]*|?.{}\\])/\\$1/;
	  print("\"$s\"\n");
	   $B =~ $s && $m++;
  }
($m/($l-$w) > 0.50) ? 1 : 0;
}
 
