|
|
| Think about Loose Coupling | |
| PerlMonks |
Re: Palindrome arrayby Athanasius (Vicar) |
| on Dec 29, 2012 at 06:04 UTC ( #1010792=note: print w/ replies, xml ) | Need Help?? |
|
The string comparison operator eq puts its operands into scalar context:
Output:
So, neither code snippet is doing what you want. The first compares the sizes of the two arrays. The second compares the size of @array with the value returned by reverse, which In scalar context, concatenates the elements of LIST and returns a string value with all characters in the opposite order. To compare the contents of the two arrays, use the smart match operator ~~. See How do I test whether two arrays or hashes are equal? Hope that helps,
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||