in reply to What is wrong with this code?
Ok, the problem is with this line:
if ($type eq 'square' or 'Square'){ #is the same as if (($type eq 'square') or ('Square')){ # is the same as if (($type eq 'square') or (1)){ # is the same as if (1) { #You want: if ($type eq 'square' or $type eq 'Square'){ #or if (lc($type) eq 'square') {
Note that the same problem is with the other to 'if' clauses further down.
As soon as you have done this you will notice the next bug: Your script will never exit and will either hang immediately or after you've gone through the "square" part. The three while loops you have there make no sense and will loop endlessly because in at least two of the three while loops the if-clause will be false and therefore the 'last' never executed. Just remove those while loops.
Maybe you wanted those while loops to ask again for the $type if the user misspelled it. In that case you need one big while loop that encloses the line where the user enters the data, i.e. " my $type=<>; "
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: What is wrong with this code?
by perl.j (Pilgrim) on Jul 24, 2011 at 00:21 UTC |