write a script to display mirror image of a entered value
and also check whether Palindrome
Answer Posted / guest
# Reverse a string and check if it is palindrome
my $str = "A man, a plan, a cat, a canal – Panama!"; # a
multiple word string
@arr = split //, $str;
my $revstr;
for (0..$#arr) {
$revstr .= join (//, pop(@arr));
}
print "reversed string: $revstr\n";
my $mod_str = $str;
$mod_str =~ (s/[\W]//g);
$revstr =~ (s/[\W]//g);
print "$str is a palindrome \n" if ( lc($mod_str) eq lc
($revstr) );
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What does `$result = f() .. g()' really return?
What does localtime() do in perl?
How to concatenate strings with perl?
What is the function of cgiwrap in cgi programming?
How to start perl in interactive mode?
What are the advantages and disadvantages of perl language?
What is v-strings?
What is Perl?
What are prefix dereferencer?
What's the difference between /^Foo/s and /^Foo/?
How to read a directory in perl?
Difference between the variables in which chomp function work ?
Where do we require ‘chomp’ and what does it mean?
What does the’$_’ symbol mean?
I have one question regarding to eval function. I know eval function is use for error checking but I am not able to understand below line. eval \'exec perl -S $0 ${1+\"$@\"}\' if 0; $0 for script name $@ set if error occur