BIOS 646 Midterm 1. a. What does the Unix command “pwd” do? b. Using the directory structure in the drawing, write the command that will get you from /home/z123456 to /var/www/cgi-bin/z123456 using an absolute path. c. Using the directory structure in the drawing, write the command that will get you from /home/z123456 to /var/www/cgi-bin/z123456 using a relative path. d. You start running a Perl script you wrote, and then you realilze it contains an infinite loop that will never finish. What command can you give to stop it? e. What command will give you (the file’s owner) permission to do anything with the file, but give members of your group read and execute permission, and all others read permission only? f. what command will create a new directory called “temp” under your current directory? g. view the names, sizes and last-modified dates (i.e. basic information about the files) of all the files in the current directory. h. What does the “less” command do? 2. You write a program and put #! usr/bin/perl –w on the first line. You get an error message that says “bad interpreter: No such file or directory”. What went wrong? 3. How do you make a comment in Perl? How do you make a comment in HTML? 4. What gets printed from this bit of code? $var = 3 / 2; $var2 = 3 % 2; $var3 = 3 ** 2; print “$var, $var2, $var3”; 5. What does “\n” stand for? What does “\t” stand for? 6. What is printed with this bit of code: $var = 53; $var .= 7; print “$var”; 7. What is printed with this bit of code: if (‘a’ le ‘A’) { print “yes”; } else { print “no”;} 8. What is printed with this bit of code: my $dog; if ($dog) { print “yes”; } else { print “no”;} 9. What does the “chomp” command do? 10. a. What are the values of $dog, and $cat after the following statement is executed? ($dog, $cat) = qw( rover fido spot rex duke fluffy); b. What are the values of @pets, $dog, and $cat after the following statement is executed? (@pets, $dog, $cat) = qw( rover fido spot rex duke fluffy); c. What is the value of @pets after the statement in part b, followed by: shift @pets; d. is the value of @pets after the statements in parts b and c, followed by: push @pets, “angel”; e. Write some code that will print every element in the array @pets, separated by semicolons (;). 11. a. Write some code that changes the value of yellow to “speed up”, after the following command was issued: %stoplight = (red => “stop”, yellow => “caution”, green => “go” ); b. Write some code to add the key “blue” with value “fly” to the %stoplight hash in the part a. c. Write some code to delete the red-stop key-value pair from the %stoplight hash in the part a. d. Write some code to print each key-value pair in the %stoplight hash in the part a. 12. How can you get the keys of a hash to print out in alphabetical order? 13. Write a bit of code that prompts the user to enter a number, then adds 3 to the number the user entered and prints it out. 14. How can you open the file “temp.txt” so you can write to it? 15. INFILE is the handle for a file opened for reading, write a bit of code that will read in each line, then print out the line number (use a counter to keep track of this) followed by the line itself. 16. On the command line a program is invoked with: "prog2.pl yes 45 fred". How can you get the program to read the second argument (the "45") into the variable $num? 17. The function “smert” is invoked with the following code. Write the smert function so it adds 3 to each input element and returns the new numbers. my @new_nums = smert(1,3,4,7,29); 18. What will be printed with the flowing code: my $var = 1; my $var2 = 2; print_sub(); sub print_sub { my $var = 9; print “A. var = $var, var2 = $var2\n”; } print “B. var = $var, var2 = $var2\n”; 19. What are the values in @arr after the following statement has executed: @arr = split /cat/, “The cat will catch a caterpillar”; 20. What is the value of $var after the following statement has executed: $str = “The cat will catch a caterpillar”; $var = substr $str, 3, 5; 21. a. Write a regular expression that matches a single character that is either A, C, G, or T. b. Write a regular expression that captures all the characters from the beginning of a line to the first space or tab character, then write the statement that puts the captured characters into the variable $var. c. Write a regular expression that will match any of the following BLAST e-values: 7.3, 0.0, 1e-7, 5e-34. d. What characters does the “\d” character class match? 22. a. What is the value of $str after the following commands are issued: $str = “GACTGGC”; $str =~ s/G/A/; b. What is the value of $str after the following commands are issued: $str = “GACTGGC”; $str =~ s/G/A/g; c. What is the value of $str after the following commands are issued: $str = “GACTGGC”; $str =~ s/g/a/; d. What is the value of $str after the following commands are issued: $str = “GACTGGC”; $str =~ s/g/A/; e. What is the value of $str after the following commands are issued: $str = “GACTGGC”; $str =~ s/g/A/i; 23. What is the value of $var after the following command has been issued: $var = “AACGTT”; $var =~ tr/AC/GT/; 24. Write the HTML statements that would produce a table with 3 rows and 2 columns, looking like this: 1 2 3 4 5 6 25. Write HTML code for a web page that has the title “Sample Page”, with a centered headline saying “This is a sample”, a link to the BIOS department (http://www.bios.niu.edu), a picture of a squirrel (squirrel.jpg), and a line of text saying “This is a line of text”.
© Copyright 2025 Paperzz