BIOS 546  Exam #1  February 13, 2001

 

 

1. Write the code for a basic HTML document, including a head with a title, and a body that repeats the title as a H2 header line, has some other regular text, and has a horizontal line in it.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2. What values evaluate to FALSE in Perl?  What values evaluate to TRUE?

 

 

 

 

 

 

 

 

3. What Linux command gives the following results:

a. the complete path to the directory you are currently in?

 

b. a list of all the files in your directory, including sizes, permissions, dates, etc. ?

 

c. removes the file "junk.txt" from your directory?

 

d. changes permission on the file "junk.txt" to allow read, write and execute permission for the owner; read and execute permission for the group; and read only permission for everyone else?

 

e. moves you to the directory /home/httpd/html?

 

f. allows you to see the contents of the file "junk.txt" one page at a time?

 

 

4. What HTML commands would give the following results:

                a. link to the site http://www.yahoo.com (be sure to include some text to click on!)

 

 

                b.insert the image "biopic.jpg"

 

 

                c. put in a comment

 

 

                d. start a new paragraph of text

 

 

                e. insert an unordered list (what tags start and end the list, and what tags are used for individual list items)

 

 

                f. insert a table (what tags start and end the table, what tags star and end the rows, and what tags are used for individual cells )

 

 

 

5. When you are changing directories, what is the difference between using an initial slash ( / ) in the path and not using the slash?

 

 

 

 

6. a.  What will:  print "The number is $num\n";  give, assuming that $num = 7.

 

 

  b. What will:  print 'The number is $num\n';  give, assuming that $num = 7.

 

 

 

 

7.What is meant by the prefixes:  $, @, and % in Perl?

 

 

 

8. To test whether two scalar variable are equal you can use either "==" or "eq".  Under what circumstances would you use one or the other?

 

 

 

9. What does the "chomp" function do?

 

 

 

10. What does the line: $a = <INFILE>;   do? Assume that INFILE is a file handle that has been correctly opened for reading.

 

 

 

11. Write a statement that will print every item in the array @arr.

 

 

 

12.  Write a statement that will insert the values 2, 4, 6, 8, 10 into an array.  Then , write a statement that will remove the first element of the array and put it into a scalar variable.  Then write another stament that will remove the last element of the array and put it into another scalar variable.  Note:  the array should have only 3 elements after all this. 

 

 

 

 

 

13.  If array @arr has the values 1,3,5,7 in it, what will the value of $a be after the statement: $a = @arr;  ?

 

 

14.  How would you get the value of the third element of array @arr?

 

 

 

15.   What is the special variable $_ ?

 

 

 

 

16. Write a statement that will print all the keys to the hash %hsh, sorted in alphabetical order.

 

 

 

17.  When would you use the "die" command in a typical application? 

 

 

 

 

18. Write two loop statements to print the numbers 1 through 5.  Use "for" in the first statement, and "foreach" in the second statement.

 

 

 

 

 

 

19.  Write a short program that will prompt the user for a color, then print "YES" if STDIN has a color that is used as a key in the hash %stoplight (i.e. red, yellow, or green), "MAYBE" if STDIN has blue or orange, and "NO" if STDIN has some other value. 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

20.  Write a short program that will read in values from the file handle INFILE and add them up.  When a value of "-1" is found, the program breaks out of the loop (without adding in the -1) and prints the sum.