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 turn on Perl warnings? Why is that important?
Define operators used in perl?
Explain the use of 'my' keyword in perl?
Give an example of using the -n and -p option.
We all know private variables exist in perl. But do private METHODS exist in perl ? Eg ?
What are the different types of perl operators?
You want to connect to sql server through perl. How would you do that?
How do I replace every character in a file with a comma?
Explain string comparison operators in perl.
How can you call a subroutine and identify a subroutine?
What is the importance of perl warnings?
How can you use Perl warnings and what is the importance to use them?
There is no strict data types in perl unlike in other high level languages like Java so wouldn't that be a problem if a code in perl is to be a written by a big team of 20+ members ?"
What is the use of '>>' in perl?
What is “grep” function in perl?