Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How do you set environment variables in perl?

983


How to dereference a reference?

935


Explain the different types of data perl can handle.

864


Define perl scripting?

941


What is the peculiarity of returning values by subroutines in perl?

862


What does the’$_’ symbol mean?

953


What is the difference between die and exit in perl?

951


Mention how many ways you can express string in Perl?

977


How do you find the length of an array?

913


what is Perl one liner?

864


Explain goto label?

879


What is the difference between use and require in perl programming?

890


What is stdin in perl?

920


Why we use CGI?

2493


What does cgi program store?

859