write a script to display mirror image of a entered value
and also check whether Palindrome
Answer Posted / guest
# Reverse a string and check if it is palindrome
my $str = "A man, a plan, a cat, a canal – Panama!"; # a
multiple word string
@arr = split //, $str;
my $revstr;
for (0..$#arr) {
$revstr .= join (//, pop(@arr));
}
print "reversed string: $revstr\n";
my $mod_str = $str;
$mod_str =~ (s/[\W]//g);
$revstr =~ (s/[\W]//g);
print "$str is a palindrome \n" if ( lc($mod_str) eq lc
($revstr) );
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How can you create anonymous subroutines?
Which operator in perl is used for the concatenation of two strings?
“Perl regular expressions match the longest string possible”. What is the name of this match?
What are some of the key features of objects in perl?
How does a “grep” function perform?
How do you turn on the perl warnings?
What are perl variables?
What is Perl?
What are the two ways to get private values inside a subroutine?
Explain grooving and shortening of arrays?
what is Chop & Chomp function does?
How to do comment in perl?
What is epoch time in perl?
What can be done for efficient parameter passing in perl?
Explain string comparison operators in perl.