Everyone has helped you with the technical problems of your script, but you should think about the usefulness of helping your brother(end user) use the script. Just think how annoying it is to type 'CIRCE' by accident, and nothing happens!

Use perl to help the typist, such as:

my $help = qq|I am an area calculator that can do the following:\n \t 1 - Square \t 2- Rectangle\n \t 3 - Paralellogram \t 4 - Trapezoid\n|; ## Add additional fu +nctions here! print "\n\n$help\n"; while ( 1 ) { print "What would you like to do? "; my $type=<>; chomp ($type); $type = lc($type); while ($type) { if ( ($type eq '1' )||( $type eq 'square') ) { $type = "Square"; say "Okay. I am working with a $type.\n"; say "ENTER SIDE LENGTH"; my $square_side = chomp(<>); my $square_area= $square_side**2; say "ANSWER= $square_area"; } elsif ( ($type eq '2' )||( $type eq 'rectangle') ) { $type = "rectangle"; # etc. . . } elsif ( $type eq '' ) { last; } else { print "\n\n$help\n"; } } } print "Thank you for using my Calculator\n";
This is untested code, so I'll leave the debugging to you. I have introduced some new functions, but the idea is to build a framework for your future work. You could add a hash or array of types. You could make each call a separate subroutine, add HTML and this could be the start of a cgi script for your web server. But best of all you have a framework for you and your brother to control your environment with perl. Maybe your brother's class mates would like to use your program and expand on it. Put a copyright on it, and now you're an author.

Learning perl now, will enable you to do and control customized things for the rest of your life.

Personally, I like that you found a real problem (your brother's learning) and you are solving it yourself.

Good start!

"Well done is better than well said." - Benjamin Franklin


In reply to Re: What is wrong with this code? by flexvault
in thread What is wrong with this code? by perl.j

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.