in reply to What is wrong with this code?
to:if ($type eq 'square' or 'Square'){
This is a precedence issue (see perlop). Since 'Square' is always true, you always get a square.if ( ($type eq 'square') or ($type eq 'Square') ){
You need to do this for your other shapes as well.
Another common way to be case-insensitive is to use lc:
One difference from your code is that this will also accept 'sQUaRe', etc.if (lc($type) eq 'square'){
See also use strict and warnings.
|
|---|