I want to write a perl program for finding the number of palindromes in a paragraph. But here I have to do it using an array. Please help.
Take a look at perlretut - Recursive patterns
.
It includes an example of testing for palindromes that you can no doubt adapt to your purposes, whatever they are exactly:
use strict;
use warnings;
my $pp = qr/^(\W* (?: (\w) (?1) \g{-1} | \w? ) \W*)$/ix;
for $s ( "saippuakauppias", "A man, a plan, a canal: Panama!" ){
print "'$s' is a palindrome\n" if $s =~ $pp;
}
Outputs:
'saippuakauppias' is a palindrome
'A man, a plan, a canal: Panama!' is a palindrome