http://www.perlmonks.org?node_id=1010469


in reply to Re^9: partial match between 2 files
in thread partial match between 2 files

I need to print the word in the file which has the maximum partial match to the inputted string.ie if the inputted string is fallen and the file has words fal,fall,falle,the value to be printed is falle.The code below gives errors

#!/usr/bin/perl-w use warnings; use strict; open my $fh1, '<', 'words' or die $!; my $a=$_; while (my $f1 = <$fh1> ) { chomp $f1; my $f2 = $a; chomp $f2; if($f2=~m/$f1/i){print"$f1\n";} }