Perl Scripts Assessment

15 Questions
Online Assessment Quizzes & Trivia

Perl Script assessment. Please note that there are 15 questions in this test.

Please wait...
Questions and Answers
  • 1. 
    File names, variables, and arrays are all not case sensitive
    • A. 

      True

    • B. 

      False

  • 2. 
    In Perl, If I have to assign the string "David paid $4.34", how the assignment statement look like?
    • A. 

      $string = "David paid ^$4.34"

    • B. 

      $string = "David paid '$4.34"

    • C. 

      $string = "David paid \$4.34"

    • D. 

      $string = David paid \$4.34

  • 3. 
    By what below means A variable cannot be  defined?
    • A. 

      ($) symbol (scalar),

    • B. 

      (@) symbol (arrays)

    • C. 

      (%) symbol (hashes).

    • D. 

      (#) symbol (pounds)

  • 4. 
    • A. 

      MondayTuesdayWednesday

    • B. 

      Syntax error

    • C. 

      Compilation error

    • D. 

      MondayWednesdayTuesday

  • 5. 
    Hashes are complex lists with both a key and a value part for each element of the list. We define a hash using the percent symbol (%) - True or False
    • A. 

      True

    • B. 

      False

  • 6. 
    • A. 

      Quarter25Dime10Nickle5 Jerry45Vickie38Tom22

    • B. 

      Dime10Nickle5Quarter25 Jerry45Vickie38Tom22

    • C. 

      Quarter25Dime10Nickle5 Tom22 Jerry45Vickie38

    • D. 

      Error

  • 7. 
    • A. 

      Offset of 7: am I about to be manipulated?! Original String: Hello, am I about to be manipulated?!

    • B. 

      Original String: about to be manipulated?! Offset of 7: am I about to be manipulated?!

    • C. 

      Error

    • D. 

      Original String: Hello, am I about to be manipulated?! Offset of 7: am I about to be manipulated?!

  • 8. 
    What is the output of the following Perl Code :#!/usr/bin/perl print "content-type: text/html \n\n"; #HTTP HEADER# DEFINE A STRING TO REPLACE$mystring = "Hello, am I about to be manipulated?!"; What is the output of the following  code : # PRINT THE ORIGINAL STRINGprint "Original String: $mystring"; # STORE A SUB STRING OF $mystring, OFFSET OF 7 AND LENGTH 10$suboffsetANDlength = substr($mystring, 7, 10);print "Offset of 7 and length of 10: $suboffsetANDlength"; # CHANGE $mystring, OFFSET OF 7 AND LENGTH 10 AND # REPLACE SUB STR WITH "I want"$suboffsetANDlength = substr($mystring, 7, 10, "I want");print "mystring is now: $mystring";
    • A. 

      Original String: Hello, am I about to be manipulated?! mystring is now: Hello, I want to be manipulated?! Offset of 7 and length of 10: am I about

    • B. 

      Original String: Hello, am I about to be manipulated?! Offset of 7 and length of 10: am I about mystring is now: Hello, I want to be manipulated?!

    • C. 

      Compilation error

    • D. 

      None of the above

  • 9. 
    What is the output of the following Perl Code:#!/usr/bin/perl print "content-type: text/html \n\n"; #HTTP HEADER # AN [email protected] = ("Quarter","Dime","Nickel"); # ADD ELEMENTSpush(@coins, "Penny");print "@coins";print "";unshift(@coins, "Dollar");print "@coins";
    • A. 

      Quarter Dime Nickel Penny Dollar Quarter Dime Nickel Penny

    • B. 

      Quarter Dime Nickel Penny Quarter Dime Nickel Penny Dollar

    • C. 

      Penny Quarter Dime Nickel Dollar Quarter Dime Nickel Penny

    • D. 

      Error

  • 10. 
    What is the output of the following perl code :#!/usr/bin/perl print "content-type: text/html \n\n"; #HTTP HEADER # SEQUENTIAL [email protected] = (1..200);@slicenums = @nums[10..20,50..60,190..200];print "@slicenums";
    • A. 

      11 12 13 14 15 16 17 18 19 20 21 51 52 53 54 55 56 57 58 59 60

    • B. 

      10 11 12 13 14 15 16 17 18 19 20 21 51 52 53 54 55 56 57 58 59 60 61 191 192 193 194 195 196 197 198 199 200

    • C. 

      Error

    • D. 

      10 11 12 13 14 15 16 17 18 19 20 21 51 52 53 54 55 56 57 58 59 60 61 191 192 193 194 195 196 197 198 199 200

  • 11. 
    A regular expression (RE) in Perl is indicated by enclosing it in forwardslashes
    • A. 

      True

    • B. 

      False

  • 12. 
    What is the output of the following Perl Code :#!/usr/bin/perl print "content-type: text/html \n\n"; #The header # SET UP THE HTML TABLEprint " "; # CREATE AN ARRAY @names = qw(Steve Bill Connor Bradley); # SET A COUNT VARIABLE$count = 1; # BEGIN THE LOOPforeach $names(@names) { print " "; $count++;}print "
    $count $names
    ";
    • A. 

      1 Steve 2 Bill 3 Connor

    • B. 

      1 Steve 2 Bill 3 Connor 4 Bradley

    • C. 

      2 Bill 3 Connor 4 Bradley

    • D. 

      Error

  • 13. 
    What is the output of the following Perl Code : #!/usr/bin/perl # HTTP HEADERprint "content-type: text/html \n\n"; # SOME VARIABLES$x = 7;$y = 7; if ($x == 7) { print '$x is equal to 7!'; print "";}if (($x == 7) || ($y == 7)) { print '$x or $y is equal to 7!'; print "";}if (($x == 7) && ($y == 7)) { print '$x and $y are equal to 7!'; print "";
    • A. 

      $x is equal to 7! $x or $y is equal to 7!

    • B. 

      $x is equal to 7! $x or $y is equal to 7! $x and $y are equal to 7!

    • C. 

      $x or $y is equal to 7! $x and $y are equal to 7!

    • D. 

      Error

  • 14. 
    • A. 

      1 2 3 Skip Four 5 6 7 Loop Finished!

    • B. 

      1 2 3 4 5 6 7 Loop Finished!

    • C. 

      1 2 3 Skip Four 5 6 7

    • D. 

      Error

  • 15. 
    A filehandle is the name of an I/O connection between your Perl process andthe outside world
    • A. 

      True

    • B. 

      False