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
What is q (single q) operator in perl?
What happens to objects lost in "unreachable" memory, such as the object returned by Ob->new() in `{ my $ap; $ap = [ Ob->new(), $ap ]; }' ?
What is confess function in perl?
Explain strftime() function in perl?
How to create a package?
What is boolean context?
What are the various uses of perl?
What are the advantages and disadvantages of perl language?
How and what are closures implemented in perl?
What is the different between array and hash in perl programming?
Explain perl.
How to print escaping characters inside a string in perl?
what is the difference between java and cgi?
Why should I use the -w argument with my Perl programs?
Explain different types of perl operators.