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 to turn on Perl warnings? Why is that important?

1058


Define operators used in perl?

933


Explain the use of 'my' keyword in perl?

1010


Give an example of using the -n and -p option.

992


We all know private variables exist in perl. But do private METHODS exist in perl ? Eg ?

2466


What are the different types of perl operators?

1066


You want to connect to sql server through perl. How would you do that?

924


How do I replace every character in a file with a comma?

973


Explain string comparison operators in perl.

1006


How can you call a subroutine and identify a subroutine?

981


What is the importance of perl warnings?

1129


How can you use Perl warnings and what is the importance to use them?

960


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 ?"

2390


What is the use of '>>' in perl?

995


What is “grep” function in perl?

991