Class 28 review (07/19/2002)

VIP: Bonus Points, 5 pts possible. Please do this, even if it is late.
  1. Search for a pattern match using PERL. See page 425 of the textbook, Figure 18.34.
       if ( $rec =~ m/$pattern/i )
    
       SYNTAX is 
                 $scalar =~/regex/option    so $rec is the $scalar,
                                               $pattern is the regex,
                                               and i is the option.
    
       The i option means ignore case.
    
       $someString = "uni panthers volleyball rules!";
       
       $someString =~ m/UNI/    would NOT find a match, because it is a case
                                   sensitive search for the pattern.
    
       $someString =~ m/UNI/i   would find a match, as the i option means
                                   the search will ignore case and treat 
                                   uni, Uni, uNi, unI, UNi, UnI, uNI and UNI
                                   all the same, matching any one of 
                                   the 8 possible ways. 
    
  2. Searching the movies database to find a pattern or word or phrase.
    • The phrase can be stored on the first line of a file, containing the pattern. If so, the user of the program specifies the file name as a command line argument, like this:
      perl  moviesSearch.p  muchado.txt
      
    • Otherwise, the PERL program prompts the user for the word or phrase, when the user just types perl moviesSearch.p to use to software.

  3. Movies and command line arguments for pattern to search for @ARGV array containing the arguments.

  4. Review of Thursday's swapping values example, with further PERL related capability demonstrated.

  5. Demonstrated the cat command with the -v and -T and -n options on it. Used to find the records with the missing tabs.
           man cat
           cat -vTn moviestabsplit.txt  |   more
    
           Here is another example, with a tiny file named junk to demo
    
    [jacobson@math-cs 088]$ cat -n junk
    
         1  here is a tab   and another     one
         2
         3  three tabs here                  bye
         4    two tabs here         yes
         5
         6  bye
    
    [jacobson@math-cs 088]$ cat -vETn junk
    
         1  here is a tab^Iand another^Ione$
         2  $
         3  three tabs here^I^I^I bye$
         4    two tabs here^I^Iyes$
         5  $
         6  bye$