The problem you have is that the $a=<STDIN> assignment includes the EOL character(s). For example, if you typed "salad", then hit the ENTER key, $a is set to "salad\n".
Since there is no "\n" in $string, nothing you type can possibly match. Add chomp($a); to remove the "\n" from $a.
Comment on Re: Perl help needed:match user input with data read from a file