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 to check the status of airplane mode (enable/disable) in perl for Android mobile?
Which has highest precedence in between list and terms? Explain?
Which statement has an initialization, condition check and increment expressions in its body? Write a syntax to use that statement.
Explain what is the scalar data and scalar variables in Perl?
How can information be put into hashes?
Explain the difference between declarations of 'my' and 'local' variable scope in perl?
How do you match one letter in the current locale?
What does next statement do in perl?
What are stdin, stdout and stderr?
What are scalars in perl?
Why to use perl scripting?
How to disable the mod_perl from apache_server as i have used perlfect search on the site and its pagination is not working and the remedy is to disable the mod_perl.
What is v-strings?
How do I sort a hash by the hash value?
How do I send e-mail from a Perl/CGI program on a Unix system?