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 ex08 directory
mkdir ex08- Go to your ex08 directory
cd ex08- 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!)Simple list printing
perl> print (1, 2, 3, 4) ; perl> print ("1", "2", "3", "4", ".") ; perl> print ("1 ", "2 ", "3 ", "4 ", ".") ; perl> $a = 35 ; perl> $b = 7 ; perl> $c = 2 ; perl> print ($a, $b, $c) ; perl> print ($a, " ", $b, " ", $c) ; perl> print ("$a ", "$b ", "$c") ; perl> print ('$a ', '$b ', '$c') ; perl> print ("$a , $b ", "$c") ; perl> print ('$a , $b ', '$c') ; perl> print ( 1 + $a , "\n" , $b * $c, "\n" , (1 + $a) / ($b - 1) ) ; perl> print ( 1 + $a , '\n' , $b * $c, '\n' , (1 + $a) / ($b - 1) ) ; perl> print ( "1 + $a" , "\n" , "$b * $c", "\n" , "(1 + $a) / ($b - 1)" ) ; perl> print ( '1 + $a' , "\n" , '$b * $c', "\n" , '(1 + $a) / ($b - 1)' ) ;(Think about the variations in output when lines of code looked fairly similar, with only slight differences...
What do you think accounts for those differences?)Other list printing
perl> print (qw/1, 2, 3, 4, 5, 6, 7/) ; perl> print (qw[1, 2, 3, 4, 5, 6, 7]) ; perl> print qw/1, 2, 3, 4, 5, 6, 7/ ; perl> print qw[1, 2, 3, 4, 5, 6, 7] ; perl> print (1..7) ; perl> print qw/1..7/ ; perl> print reverse (1, 2, 3, 4, 5, 6, 7) ; perl> print reverse qw/1, 2, 3, 4, 5, 6, 7/ ; perl> print (-7..7) ; perl> print reverse (-7..7) ;(Did any of the results seem odd or anomalous?
What do you think accounts for those anomalies?)Individual elements and list slices
perl> print (1, 2, 3, 4, 5, 6, 7)[0] ; perl> print ( (1, 2, 3, 4, 5, 6, 7)[0] ) ; perl> for ($i = 0 ; $i < 7 ; $i++) { print ( (1, 2, 3, 4, 5, 6, 7)[$i] ) ; print "\n"; } perl> for ($i = 6 ; $i >= 0 ; $i--) { print ( (1, 2, 3, 4, 5, 6, 7)[$i], "\n" ) ; } perl> print ( (1, 2, 3, 4, 5, 6, 7)[0..3] ) ; perl> print ( (1, 2, 3, 4, 5, 6, 7)[1..4] ) ; perl> print ( (1, 2, 3, 4, 5, 6, 7)[4..1] ) ; perl> print ( (qw/1, 2, 3, 4, 5, 6, 7/)[2] ) ; perl> print ( (qw/1, 2, 3, 4, 5, 6, 7/)[2..5] ) ; perl> print ( qw/1, 2, 3, 4, 5, 6, 7/[2] ) ; perl> print ( qw/1, 2, 3, 4, 5, 6, 7/[-1] ) ; perl> for ($i = -7 ; $i < 0 ; $i++) { print qw/1, 2, 3, 4, 5, 6, 7/[$i] ; print "\n"; } perl> print ( (qw/1, 2, 3, 4, 5, 6, 7/)[-5..-2] ) ; perl> for ($i = 0 ; $i < 7 ; $i++) { print ( (reverse(1, 2, 3, 4, 5, 6, 7))[$i] ) ; print "\n"; }(How many results conformed to your predictions? How many did not
What do you think accounts for those differences?)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.