Camerontainium has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks! I am new to perl and have a question. I am trying to make a palindrome program for class. Our teacher wants us to use chop but I am a little lost. Do I need to join the @userinput array? I tried doing that but everytime I run the program it says palindrome not my else statement. any help is appreciated
my (@userinput, $user, $a, $b, $c, $d, $e, $f, $g, $h, $i); print "\nThis program asks for you to \n enter any nine character sequence and \n then tells you if it is a palidrome!\n\n"; print "Please enter your sequence "; ($user = <>); $a = chop ($user); $b = chop ($user); $c = chop ($user); $d = chop ($user); $e = chop ($user); $f = chop ($user); $g = chop ($user); $h = chop ($user); $i = chop ($user); @userinput = ($i, $h, $g, $f, $e, $d, $c, $b, $a) if ($user = @userinput) { print "PALIDROME!"; } else { print "NOT A PALIDROME!"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Please help
by roboticus (Chancellor) on Mar 27, 2012 at 16:24 UTC | |
|
Re: Please help
by MidLifeXis (Monsignor) on Mar 27, 2012 at 16:23 UTC | |
|
Re: Please help
by jeffa (Bishop) on Mar 27, 2012 at 16:05 UTC | |
by Camerontainium (Initiate) on Mar 27, 2012 at 18:48 UTC | |
by Tux (Canon) on Mar 27, 2012 at 19:23 UTC | |
by ww (Archbishop) on Mar 27, 2012 at 19:51 UTC | |
|
Re: Please help
by tobyink (Canon) on Mar 27, 2012 at 16:58 UTC | |
by CountZero (Bishop) on Mar 27, 2012 at 21:33 UTC | |
by tobyink (Canon) on Mar 27, 2012 at 21:41 UTC | |
by Happy-the-monk (Canon) on Mar 27, 2012 at 19:11 UTC | |
by Not_a_Number (Prior) on Mar 27, 2012 at 19:41 UTC |