CIW Course Revision Site

Tutor Marked Assignment PL TMA-07

In a Nutshell - CIW Course Section 2 Part B

PL TMA-07 - CD Access Code: 18480

Q1. What is a filehandle?

Q2. The scalar $filename, the hash %filename, the array @filename, the label filename, and the filehandle FILENAME can not be used in the same script without danger of a name conflict.

Q3. Connect each file name prefix used in the open function with their correct function.

 

Q4. Which of these functions is commonly used if the opening of the file is not successful?

Q5. What will be displayed by the following Perl statements?

open (DATA, "+=data.txt");
print (DATA "where am I\n");
close (DATA);

Q6. Which of these statements will point the cursor 2 bytes before the end of the file used in the previous question?

Q7. Connect the following file test operators with their correct function.

 

Q8. The stat function returns a list of data concerning a particular file. How many elements are in this list?

Q9. Which of the following statements related to environmental variables are true and which are false?

Not sure what these "environmental" variables are. I am familiar with "environment" variables as used in Windows and other operating systems.

Q10. What would be displayed by the following Perl statements on a Windows based computer?

print $ENV{"HOME"};

Q11. What would be displayed by the following Perl statements?

foreach $key (sort keys(%ENV)) {
    print ("$key\t$ENV{$key}\n");
}

Q12. Changing the $ENV{"PATH"} variable in a script can force the system to search directories that you specify.

Q13. What would be displayed by the following Perl statements if the program is run using perl program.pl -x -e -t?

$arg = $#ARGV + 1; $x = 1;
print "Count of arguments: " $arg. Arguments: ";
foreach (@ARGV) {
    print "$_";
    if ($x != $arg) { print ", "; }
    $x++;
}

Q14. A filehandle can be defined either by an expression that evaluates to the filehandle name or by a ________?

Q15. In Perl, it is convention to write filenames in uppercase letters.

Design by Stephen

Certified Internet Webmaster

Page last Edited: 25 Nov 2011