|XP is just a number|
Re: Please Helpby kcott (Canon)
|on Sep 29, 2012 at 23:28 UTC||Need Help??|
Welcome to the monastery.
The following should be sufficient information for you to complete your class assignment.
The perldoc.perl.org site should provide most, if not all, of the documentation you need while initially learning Perl. I have it bookmarked and use it often; I suggest you do the same. I've included a number of links to documentation below - all to pages on this site.
After the shebang line (that's the #!... on line 1) put:
When you do this, Perl will tell you about mistakes you've made or potentially problematic code you're attempting to run. While you're learning Perl, you should do this in all of your scripts. See strict and warnings.
The line read -p "What is your name: " name is not Perl: it works in bash (and probably other shells). The typical way to achieve what you want here is with something like:
The first line should be self-explanatory - single-quotes are for literal text (see print).
In the next line my declares a lexical variable: Perl has various types of variables - you'll use this type most often and it's all you need for this type of script. Unlike bash, where you assign to varname then read from $varname, in Perl you use $varname in both cases. The <> reads from standard input (in your case, this is what you type at the keyboard). One important point to note is that it reads the text you type as well as the newline you enter to terminate your input. You can read about it in perlop - I/O Operators but you may find that rather heavy going: it certainly has far more information than you need for this script.
Finally, you print whatever the user typed, including the newline.
That handles getting the input you need. Note that there's no checking of this input: the user could have just typed a newline for name and something that isn't a number for income. I suspect that's not a requirement for your assignment: add a comment in your code stating that no validation is performed to indicate that you are aware of this limitation in your script. (If it is a requirement, come back and ask a follow-up question.)
All of your conditions use bash (or other shell) code again (-lt and -gt). See perlop - Relational Operators for the Perl equivalents - note that there's different operators for string and numerical comparisons.