Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Palindrome array

by davido (Archbishop)
on Dec 29, 2012 at 09:47 UTC ( #1010807=note: print w/ replies, xml ) Need Help??


in reply to Palindrome array

There are a number of good ways to approach this. Here's one way that uses a CPAN module:

use String::Palindrome qw( is_palindrome ); my @array = qw( x a m a x ); print "@array ", is_palindrome( @array ) ? "is" : "isn't ", "palindromic.\n";

The above solution works just as well if you pass it a string rather than an array, but in either case it does the job.


Dave


Comment on Re: Palindrome array
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010807]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (15)
As of 2015-07-02 17:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (44 votes), past polls