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 many data types are there in perl?
What is a perl references?
Which has highest precedence in between list and terms? Explain?
What are perl variables?
Does Perl have reference type?
How will you create a file in perl?
What is perl dbi?
Explain the use of 'my' keyword in perl?
Explain lexical variables.
What are different data types that perl supports. Elaborate on them.
Why do you use Perl?
How to renaming a file in perl programming?
What is the purpose of _package_ literal?
Explain ivalue?
How to open a directory in perl?