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
Define operators used in perl?
What is qq (double q)operator in perl?
What are some common methods to all handles in perl?
Explain ivalue in perl?
how to create a flat file database as shown below s.no name age city phone 0 hema 22 Calcutta 4312542 1 hema 21 Bangalore 2344345 2 ganesh 25 delhi 2445454 3 kartik 45 pune 4312121 4 santosh 25 Hyderabad 2254231 5 kumar 25 mysore 2344567 6 gita 34 mangalore 6532123 7 gita 32 pune 2213456 Q1.print the details of the person who r from bangalore q2.Replace the city name managlore to pune q3.prints no of person having name gita and hema q4.print how many are of age 25.
What is the main function of cookie server?
You want to empty an array. How would you do that?
What is 'commit' command in perl?
There are two types of eval statements i.e. Eval expr and eval block. Explain them.
What is 'rollback' command in perl?
What are the various uses of perl?
What $! In perl?
Why should I use the -w argument with my Perl programs?
What is cpan in perl?
Which has the highest precedence, List or Terms? Explain?