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 / narayan singh

print("Enter the no. to check for Palindrome : ");
$no = <STDIN>;
chop($no);

$i = 0;

# Store into a array
while($no != 0)
{
@array[$i] = $no % 10;
$no = int($no / 10);
$i++;
}

$i--;
$j=0;
$flag = "true";

# Check for Palindrome
while( ($flag eq "true" )&& ( $j < @array/2) ){
if (@array[$j] != @array[$i])
{
$flag = "false"
}
$i--;
$j++;
}

# Print the result
if( $flag eq "true")
{
print("It is a Palindrome\n");
}
else
{
print("It is NOT a Palindrome\n");
}

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I do fill_in_the_blank for each file in a directory?

911


Explain 'grep' function.

926


Why should I use the -w argument with my Perl programs?

917


How to renaming a file in perl programming?

973


You want to open and read data files with perl. How would you do that?

839


What is perl programming?

961


How can I display all array element in which each element will display on next line in perl ?

864


How do you turn on the perl warnings?

859


Explain perl. When do you use perl for programming? What are the advantages of programming in perl?

825


what are the two ways to get private values inside a subroutine or block?

878


What are the arguements we normally use for perl interpreter?

906


List the data types that Perl can handle?

968


What is posix in perl?

878


What are arrays in perl?

920


Write a program that explains the symbolic table clearly.

913