use strict; use warnings; use re 'eval'; print "Enter word: "; #chomp(my $word = ); my $word = "zek"; #read the string and trip it into 2 characters NB: /g to repeat operation at same string my @pairs = $word =~ /(?=(..))/g; print(" \"@pairs\" \n"); #qr to make an expression \1 at the end eats matched! #consider grep perl #my $matcher = qr/(?=(?s-i)(@{[join "|", @pairs]}))/; #my $matcher = qr/(?=(@{[join "|", @pairs]}))/; local $" = q{|}; my $matcher = qr{(?=(@pairs))}; print(" \"$matcher\" \n"); my %coef; open (my $dict, "dictionary.txt") || die "cant open dictionary.txt\n"; my $dictword = "zezezl"; my $matches = () = $dictword =~ /$matcher/g; (print"$_")yes-pattern/g; my $totalz = "$matches $dictword \n"; print $totalz; my $coef = 2 * $matches / (@pairs + length($dictword)-1); print ("coeffesion score is $coef");