Perl Quiz (Set 2) Perl (Set 2) 1 / 14 What is the difference between 'sort' and 'reverse'? sort is more efficient than reverse reverse is more efficient than sort sort sorts an array in ascending order, while reverse sorts an array in descending order 2 / 14 What is the purpose of the 'sub' keyword? sub keywords are used to define functions sub keywords are used to define subroutines sub keywords are used to define variables 3 / 14 What is the purpose of the 'eval' function? eval functions are more efficient than regular expressions eval functions are less efficient than regular expressions eval functions evaluate a string as Perl code 4 / 14 What is the purpose of the 'die' keyword? To terminate the program and print an error message To terminate the program without printing an error message To execute a loop To define a subroutine 5 / 14 What is the difference between 'scalar' and 'list' context? scalar context is more efficient than list context scalar context is used when a variable is used by itself, while list context is used when a variable is used in a list list context is more efficient than scalar context 6 / 14 What is the difference between 'local' and 'my' variables? local variables are only visible within the scope in which they are defined, while my variables are visible throughout the entire program local variables are more efficient than my variables my variables are more efficient than local variables 7 / 14 What is the purpose of the 'continue' statement? continue statements terminates the current loop continue statements terminates the current function continue statements skips the rest of the current iteration of the loop 8 / 14 What is the purpose of the 'break' statement? break statements terminate the current function break statements terminate the current loop break statements terminate the current program 9 / 14 What is the purpose of the 'foreach' loop? foreach loops iterate over an array foreach loops are more efficient than for loops for loops are more efficient than foreach loops 10 / 14 What is the purpose of the 'for' loop? for loops are more efficient than foreach loops foreach loops are more efficient than for loops for loops iterate over a range of numbers 11 / 14 What is the purpose of the 'do'...'while' loop? do...while loops are more efficient than for loops do...while loops execute code once, then check the condition; if the condition is true, the code is executed again for loops are more efficient than do...while loops 12 / 14 What is the purpose of the 'while' loop? while loops are more efficient than for loops for loops are more efficient than while loops while loops execute code while the condition is true 13 / 14 What is the purpose of the 'and' and 'or' operators? The and operator is more efficient than the or operator The and operator returns true if both operands are true, while the or operator returns true if either operand is true The or operator is more efficient than the and operator 14 / 14 What is the difference between 'if' and 'unless'? if statements execute code if the condition is true, while unless statements execute code if the condition is false if statements are more efficient than unless statements unless statements are more efficient than if statements Your score isThe average score is 0% 0% Restart quiz