It looks correct. A few points:

  1. You might as well use the unix splatline, since winders ignores it anyway: #!/usr/bin/perl
  2. That style of bracketing and indentation is painful. The recommendations in perlstyle are a good guide to making perl readable to perlers.
  3. That's good practice reading and checking the $numn variables. I think you should use the same care with $sign.
  4. This one may be new to you. Instead of all those if statements, you could make an array of code references to what you want to do, given $sign, and call the correct code directly. That would be a form of dispatch table
    our @codes = ( sub {}, sub { my ($n1, $n2) = @_; print "The Sum of the Numbers $n1 + $n2 is ", $n1 + $n2, "\n"; }, sub { my ($n1, $n2) = @_; print "The Difference of the Numbers $n1 - $n2 is ", $n1 - $n2 +, "\n"; }, # . . . ); $codes[$sign]->($num1, $num2);
  5. For a further simplification, the different messages could be stored in an array to help unify the different subs. Where things look repetitive, you can generally reduce the problem by removing the repetition.

After Compline,
Zaxo


In reply to Re: My second script by Zaxo
in thread My second script by hozefa

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.