Hi! Monks,
Why does the first code work, but not the second one? Can you help me understand. Thank you!
#!/usr/bin/perl use warnings; use strict; use 5.010; my @array = qw(x a m a x); my @reversed = reverse @array; if (@array eq @reversed){ say "this's a palindrome."; } else { say "this's not a palindrome"; }
#!/usr/bin/perl use warnings; use strict; use 5.010; my @array = qw(x a m a x); if (@array eq (reverse @array)){ say "this's a palindrome."; } else { say "this's not a palindrome."; }
In reply to Palindrome array by rnaeye
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |