maheshkumar has asked for the wisdom of the Perl Monks concerning the following question:
I wrote the following code and when I take an string input from the user the Strings do not match, whereas if I just define a string then they match. What is the problem with the following code as it is giving "It does not match"
Thanksprint "Enter a word: \n"; $string1 = <STDIN>; $string2 = 'Mahesh'; if($string1 eq $string2){ print "Match \n"; } else { print "Does not match \n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comparing Strings
by Anonymous Monk on Jun 23, 2012 at 11:09 UTC | |
|
Re: Comparing Strings
by BrowserUk (Patriarch) on Jun 23, 2012 at 11:10 UTC | |
|
Re: Comparing Strings
by Anonymous Monk on Jun 23, 2012 at 12:45 UTC | |
|
Re: Comparing Strings
by 7stud (Deacon) on Jun 24, 2012 at 05:05 UTC | |
|
Re: Comparing Strings
by Khen1950fx (Canon) on Jun 24, 2012 at 13:56 UTC | |
by AnomalousMonk (Archbishop) on Jun 24, 2012 at 20:24 UTC |