Chủ Nhật, 6 tháng 6, 2010

Câu hỏi luyện tập Perl

Một vài câu hỏi dùng trong quá trình dạy perl tại aiti-aptech

Perl Question

  1. What is the address of Perl's home page?

  2. Who was the creator of Perl?

  3. How much does Perl cost?

  4. Why are comments important to programming?

  5. What are the four types of literals?

  6. What is a numeric literal?

  7. How many types of string literals are there?

  8. What is the major difference between single- and double-quoted strings?

  9. What are three escape sequences and what do they mean?

  10. What would the following one-line program display?
    print `dir /*.log`;


  11. What is scientific notation?

  12. How can you represent the number 64 in hexadecimal inside a double-quoted string?

  13. What is the easiest way to represent an array that includes the numbers 56 to 87?

  14. What are the three basic data types that Perl uses?

  15. How can you determine the number of elements in an array?

  16. What is a namespace?

  17. What is the special variable $[ used for?

  18. What is the special variable $" used for?

  19. What is the value of a variable when it is first used?

  20. What is an associative array?

  21. How can you access associative array elements?

  22. What are three arithmetic operators?

  23. What does the x operator do?

  24. What does it mean to pre-decrement a variable?

  25. What is the value of 1 ^ 1?

  26. What is the value of 1 << 3?

  27. What is the ternary operator used for?

  28. Can the x operator be used with arrays?

  29. What is the precedence level of the range operator?

  30. What is the value of 2 * 5 + 10?

  31. What is the value of 65 >> 1?

  32. What is the spaceship operator used for?

  33. If an array were defined with ("fy".."gb"), what would its elements be?

  34. What is a parameter?

  35. What two functions are used to create variables with local scope?

  36. What does parameter passing by reference mean?

  37. What is the @_ array used for?

  38. Do Perl variables have global or local scope by default?

  39. Why is it hard to pass two arrays to a function?

  40. What is the difference between variables created with local() and variables created with my()?

  41. What does the map() function do?

  42. What is an expression?

  43. What is a statement?

  44. What are the four statement modifiers?

  45. What are two uses for statement blocks?

  46. What can non-action statements be used for?

  47. How is the if modifier different from the unless modifier?

  48. What will the following code display?
    $firstVar = 10;
    $secondVar = 20;

    $firstVar += $secondVar++ if ($firstVar > 10);

    print("firstVar = $firstVar\n");
    print("secondVar = $secondVar\n");


  49. What are the four loop keywords?

  50. What are the four jump keywords?

  51. Which form of the until statement is used when the statement block needs to be executed at least once?

  52. What will be displayed when this program executes?
    $firstVar = 5;
    {
    if ($firstVar > 10) {
    last;
    }
    $firstVar++;
    redo;
    }
    print("$firstVar\n");


  53. What is the default name of the local variable in the foreach loop?

  54. How is the next keyword different from the redo keyword?

  55. Why is the comma operator useful in the initialization expression of a for loop?

  56. What is the shift() function used for?

  57. What is a reference?

  58. How many types of references are there?

  59. What does the ref() function return if passed a non-reference as a parameter?

  60. What notation is used to dereference a reference value?

  61. What is an anonymous array?

  62. What is a nested data structure?

  63. What will the following line of code display?
    print("${\ref(\(1..5))}");


  64. Using the %database array in Listing 8.6, what will the following line of code display?
    print(%{$database{"MRD-100"}}->{"Zip"} . "\n");


  65. What is a file handle?

  66. What is binary mode?

  67. What is a fully qualified file name?

  68. Are variables in the computer's memory considered persistent storage?

  69. What is the <> operator used for?

  70. What is the default file handle for the printf() function?

  71. What is the difference between the following two open statements?


 open(FILE_ONE, ">FILE_ONE.DAT");
open(FILE_TWO, ">>FILE_TWO.DAT");


  1. What value will the following expression return?
     (stat("09lst01.pl"))[7];


  2. What is globbing?

  3. Can you use variable interpolation with the translation operator?

  4. What happens if the pattern is empty?

  5. What variable does the substitution operator use as its default?

  6. Will the following line of code work?
     m{.*];


  7. What is the /g option of the substitution operator used for?

  8. What does the \d meta-character sequence mean?

  9. What is the meaning of the dollar sign in the following pattern?
    /AA[.<]$]ER/


  10. What is a word boundary?

  11. What is the syntax of the format statement?

  12. What is a footer?

  13. What function is used to invoke the format statement?

  14. How can you change a detail format line into a header format line?

  15. What is the > format character used for?

  16. What is the $^L variable used for?

  17. Can associative array variables be used in value lines?

  18. What is the $/ variable used for?

  19. What file handle is used to avoid a second system call when doing two or more file tests?

  20. What will the following program display?
    $_ = "The big red shoe";
    m/[rs].*\b/;
    print("$`\n");


  21. What variable holds the value of the last match string?

  22. Why is it important to check for errors?

  23. How is the die() function different from the warn() function?

  24. What is the meaning of the $! special variable?

  25. What does the eval() function do?

  26. What is a signal?

  27. What will the statement $SIG{'ABRT'} = 'IGNORE' do??

  28. Which signal is used to trap floating point exceptions?

  29. What will the following program display?
    @array = (1..5);
    $" = "+";
    print("@array\n");


  30. What does the following program display?
    @array = ('A'..'E');

    foreach (@array) {
    print();
    }

    $\ = "\n";
    foreach (@array) {
    print();
    }


  31. What will the following line of code do?
    select((select(ANNUAL_RPT), $^ = "REGIONAL_SALES")[0]);


  32. What will be displayed by the following program?
    $_ = 'AB AB AC';
    print m/c$/i;


  33. What will the following statement display?


 printf("%x", 16);

3 nhận xét:

  1. Great post. Just found it on Bing. tks 4 the useful info. Keep up the great work :)

    Trả lờiXóa
  2. so useful.hehe.thanks for your share.

    Trả lờiXóa