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


in reply to Comparing Strings

When the user types something in response your prompt:

Enter a word:

(which by the way would be better without the "\n"), they type in a word, and then they hit Return; and when they hit Return an invisible newline character is entered into the input stream:

Enter a word: Mahesh\n

So your $string1 variable will look like this:

$string1 = "Mahesh\n"

...and that will never be eq to the string "Mahesh"