Class #2 - PERL - Wednesday


  1. The Shebang Line is covered on pages 34 and 35.
        Exercise:  login to cowboy.cns.uni.edu and try the
    
                      which perl 
                                 command to see what the output is.
    
  2. Information on UNIX commands (cowboy.cns.uni.edu) and links to HTML info.

  3. Read Appendix C - pages 291-294 - Permissions on Unix.
     
    chmod 755 myFile.txt
    ls -l myFile.txt
    -rwxr-xr-x       myFile.txt
    
    chmod 644 myFile.txt
    ls -l myFile.txt
    -rw-r--r--       myFile.txt
    
    In octal (base 8) and in binary (base 2) we have   Octal  Binary  ls -l
                                                         0      000    ---
                                                         1      001    --x
                                                         2      010    -w-
                                                         3      011    -wx
                                                         4      100    r--
                                                         5      101    r-x
                                                         6      110    rw-
                                                         7      111    rwx
                                                        ---     ---    ---
                                                                rwx    421
    
    As stated on page 292 of Elizabeth Castro book,
    you assign a value of 4 for read permission,
                          2 for write permission, and
                          1 for execute permission.
    
    Saying chmod 755 fileName.txt means you are giving all permissions 
                                  to yourself (the owner of fileName.txt),
                                  since 7 = 4 + 2 + 1 = 111 in binary.
                                 
                                  You are giving read and execute permissions
                                  to your group and everyone else (others),
                                  because 4 = read and 1 = execute, and
                                  4 + 1 = 5 and 5 = 101 in binary, or r-x
                                                                      101
    
  4. Transliteration, page 227 of the textbook. How was this illustrated in class?
       Here is the statement we looked at in randomGenX.cgi PERL script:
    
                         $quoteList =~ tr/ //d;
    
       The user could type in 1,  5 - 7 , 9 
                                            and it would be transliterated
                           to 1,5-7,9 
                                            by the     $quoteList =~ tr/ //d;
                                            statement.
       The d stands for delete.
     
       ---------------------------------------------------------------------
       What would the following PERL statements do?
       
       print "Please enter data to be processed by the transliteration " .
             "function: \n\n";
    
       $someData = <>;
       print "\nYou entered: $someData";
       $someData =~ tr/a-z/b-za/;
       print "\n  It is now: $someData\n\n";
    

    Please enter data to be processed by the transliteration function:
    
    UNI Panthers rock and roll, especially volleyball!  Feb 19th, 2003
    
    You entered: UNI Panthers rock and roll, especially volleyball!  Feb 19th, 2003
    
      It is now: UNI Pbouifst spdl boe spmm, ftqfdjbmmz wpmmfzcbmm!  Ffc 19ui, 2003
    
  5. What is CGI.pm and what is CGI.pm's param() function? See page 104. Here is the code from randomGenX.cgi. What was quoteNumbers? You can see WHAT quoteNumbers is right here, and try out the PERL CGI application.
    use CGI qw(:standard);
    
    $quoteList = param('quoteNumbers');
    
  6. UNIX ESSENTIALS - Appendix D of the book - pages 295-303 Also, check out this local information and these other links too.