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
How to check the status of airplane mode (enable/disable) in perl for Android mobile?
Explain chop?
What is hash?
Is there any way to add two arrays together?
How do you you check the return code of a command in perl?
How many types of operators are used in the Perl?
Explain the various characteristics of perl.
What are the arguements we normally use for perl interpreter?
What is eval function in perl?
Explain what is perl language?
Explain arrays in perl.
What are numeric operators in perl?
What is perl programming?
Explain the internal working of cgi
How do I read command-line arguments with Perl?