Welcome to PerlMonks!
Here is how I would have done your code:
#!/usr/bin/perl -w use strict; my($input,$hrate,$yrate,$x); while(!defined $x){ print "Do you wish to calculate yearly salary (y) or hourly rate (h) +:"; chomp($input=<STDIN>); if($input=~/y/i){ # I am just guessing that this is what you're # trying to do print "Enter your yearly salary: "; chomp ($yrate=<STDIN>); $hrate=($yrate/52)/40; printf("You make \$%2d per hour.",$hrate); $x=1; }elsif($input=~/h/i){ print "Enter your hourly rate: "; chomp ($hrate=<STDIN>); $yrate=($hrate * 40)*52; print"\nYour yearly salary is \$$yrate\n"; $x=1; }else{ print"Please enter either h or y.\n\n"; sleep 2; ) }
By using strict, you will catch accidental misspellings and make you declare your variables. The way that your code is right now, you don't see the last line of it,until you do a control-C out of the program. Mine will do one of the calculations then exit. When checking the input with a regular expression, I used the "i" modifier which means that if the user has their caps lock key on, it will still accept it.

TStanley
--------
The only thing necessary for the triumph of evil is for good men to do nothing -- Edmund Burke

In reply to Re: New to Programming and I have chose PERL by TStanley
in thread New to Programming and I have chose PERL by snowsurfer

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.