CIW Course Revision Site


Tutor Marked Assignment PL TMA-03

In a Nutshell - CIW Course Section 2 Part B

PL TMA-03 - CD Access Code: 7866

Q1. When using the foreach statement, the control variable is written as what?

Q2. Given the following array declaration, which statement would display the last element from the array?

@seasons = ("Spring", "Summer", "Autumn", "Winter");

Q3. Perl arrays can contain string or numerical values, but not both.

Q4. What would be the output from the following Perl coding?

@array1 =!19..14);
@array2 = (9, @array1, 14, 15);
print ("array2");

Q5. What would be the output from the following Perl coding?

@array1 = (10..13);
@array2 = @array1;
$array1[0] = 9;
print ("@array2");

Q6. What would be the output from the following Perl coding?

@array = "3, 6, 5, 4, 1);
@array = sort {$a <=> $b} @array;
$array[0] = 2;
print ("@array");

Q7. What would be the output from the following Perl coding?

@array = (3, 6, 5, 4, 1);
$array[$#array] = 7;
@array = sort {$b <=> $a} @array;
print ("@array");

Q8. What would be the output from the following Perl coding?

@array = {"Tom", "Dick", "Harry");
sort {$b cmp $a} @array;
print ("@array");

Q9. What would be the output from the following Perl coding?

@array = (10, 7, 3, 8, 13, 4, 2);
push(@array, shift(@array));
@array = sort {$b <=> $a} @array;
print ("@array");

Q10. What would be the output from the following Perl coding?

@array = (10 3..8, 13, 2);
shift(@array);
unshift(@array, 9);
pop(@array);
print ("$#array");

Design by Stephen

Certified Internet Webmaster

Page last Edited: 25 Nov 2011