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
Explain perl. What are the advantages of programming in perl?
How to dereference a reference?
What is Perl?
How to read file into hash array ?
What are the arguments and what do they mean in perl programming?
What is automatic error handling in perl?
How do I replace every TAB character in a file with a comma?
Hi, I am a accountant. I am preparing a balance sheet but because of staff shortage and time pressures I cant complete it on time. There is lot of common data with last years which I need not retype and I can manage by editing last year’s balance sheet ? Is their any software on net where I can do this easily??
Explain the execution of a program in perl.
What interface used in PERL to connect to database? How do you connect to database in Perl?
What are hashes?
Explain 'grep' function.
Explain the difference between die and exit in perl?
How to read a file into a hash array?
How can you call a subroutine and identify a subroutine?