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 do you set environment variables in perl?
How to dereference a reference?
Explain the different types of data perl can handle.
Define perl scripting?
What is the peculiarity of returning values by subroutines in perl?
What does the’$_’ symbol mean?
What is the difference between die and exit in perl?
Mention how many ways you can express string in Perl?
How do you find the length of an array?
what is Perl one liner?
Explain goto label?
What is the difference between use and require in perl programming?
What is stdin in perl?
Why we use CGI?
What does cgi program store?