Log in to users.cs.umb.edu
- Log in to a Windows machine
Enter your Unix username as the account name. Then enter your password.- Run the ssh client
Use the values in the table below to connect to users.
ssh configuration parameter value protocol ssh ssh version 2 ssh port 22 host users.cs.umb.edu user name your unix username Authentication method password Enter your password
A dialog box will appear on the screen into which you must type the password for your Unix account.- Make sure you are in your home directory
cd- Go to your it441 directory
cd it441- Go to your ex directory
cd ex- Create an ex03 directory
mkdir ex03- Go to your ex03 directory
cd ex03- Execute the script command
script- Use your perlsession alias to start the re.pl script.
perlsession(NOTE: If the perlsession alias is not recognized, or if re.pl cannot run, then double-check your Perl configuration, as well as your login shell vs. subshell environments!)Just so that you understand what you are doing here, when you see an item like this...perl> $int_numb = 57 ;
...that means you have the prompt perl> , at which you should type the following Perl code $int_numb = 57 ; and press Enter. The resulting session will feature the Perl prompt, the code you type, and any output that results.Also, in terms of entering the code at the prompt, you may in fact find it easier to copy the code from your browser and paste it in at the Perl prompt. This way, you can focus your attention less on typing and more on comprehending the code:
Asking questions like these and experimenting are how you develop your skill at Perl programming and many other tasks!
- What are the parts to the code?
- Why are they here?
- How do they contribute to the output/result?
- If you changed the code, in one way or another, how would that affect the output/result?
Practice with scalar variable types
- Integer numbers
perl> $int_numb = 57 ; perl> print $int_numb ;- Floating point numbers
perl> $decimal = 85.35 ; perl> print $decimal ;- Long integer numbers
perl> $long_int = 10000000000000000001 ; perl> print $long_int ;- Strings
perl> $team = 'Red Sox' ; perl> print $team ;Practice with variable names
- Meaningful variable names
perl> $first_name = "Dustin" ; perl> $last_name = "Pedroia" ; perl> print $first_name . " " . $last_name ;- Long variable names
perl> $number_of_times_the_sox_have_won_world_series_this_century = 3 ; perl> print $number_of_times_the_sox_have_won_world_series_this_century ;(Does this work? If not, why? If so, why shouldn't you do it?)
- Illegal variable names
perl> S1st_name = 'Koji' ; perl> Sclass = 'IT 441' ;Practice with operators
- Arithmetic operators
perl> print 4 + 5 ; perl> print 4 - 5 ; perl> print 4 * 5 ; perl> print 20 / 5 ; perl> print 20 / 3 ; perl> print int (20 / 3) ; perl> print 20 % 3 ; perl> print 2 ** 3 ;- String operators
perl> $team = 'Red Sox' ; perl> $city = "Boston" ; perl> print $city . " " . $team ; perl> print $team x 3 ; perl> $new_team = $team x 3 ; perl> print $new_team ;Practice with statements
- print statement
perl> print "I root for the ", $city, " ", $team ;Practice with the rules of precedence
- Define some variables
perl> $a = 3 ; perl> $b = 4 ; perl> $c = 5 ;- Addition and multiplication operators
perl> print $a + $b * $c ; perl> print ($a + $b) * $c ;- Subtraction and division operators
perl> print $a - $b ; perl> print $a - $b / $c ; perl> print $b / $c ; perl> print ($a - $b) / $c ; perl> print $c % $b - $a ; perl> c % b ; perl> print $c % ($b - $a) ;- Exponentiation
perl> print $c - $a ** $b ; perl> print $a ** $b ; perl> print ($c - $a) ** $b ;- End the Perl Session
perl> exitEnd the script session
Use the exit command. You should then have a file called typescript in your current working directory.