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
Explain string comparison operators in perl.
Explain the arguments for perl interpreter.
Explain gmtime() function in perl?
What does undef function in perl?
How to connect to SQL server through Perl?
Explain subroutine in perl?
How can you call a subroutine and identify a subroutine?
What are prefix dereferencer?
How do I replace every character in a file with a comma?
List the data types that Perl can handle?
Explain lists and ivalue?
How do find the length of an array?
In Perl we can show the warnings using some options in order to reduce or avoid the errors. What are that options?
What is perl I used for?
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.