Perl Scripts Assessment

15 Questions | Attempts: 338
Share

SettingsSettingsSettings
Online Assessment Quizzes & Trivia

Perl Script assessment.

Please note that there are 15 questions in this test.


Questions and Answers
  • 1. 

    File names, variables, and arrays are all not case sensitive

    • A.

      True

    • B.

      False

    Correct Answer
    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

    Correct Answer
    C. $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)

    Correct Answer
    D. (#) symbol (pounds)
  • 4. 

    What is the ouput of the below perl code : Using Arrays:@days = ("Monday", "Tuesday", "Wednesday");print @days;

    • A.

      MondayTuesdayWednesday

    • B.

      Syntax error

    • C.

      Compilation error

    • D.

      MondayWednesdayTuesday

    Correct Answer
    A. MondayTuesdayWednesday
  • 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

    Correct Answer
    A. True
  • 6. 

    What is the ouput of the below perl code : print "Content-type: text/html \n\n"; #HTTP HEADER #DEFINE SOME ARRAYS%coins = ("Quarter", 25, "Dime", 10, "Nickle", 5);%ages = ("Jerry", 45, "Tom", 22, "Vickie", 38); #PRINT MY HASHES TO THE BROWSERprint %coins;print "";print %ages;

    • A.

      Quarter25Dime10Nickle5 Jerry45Vickie38Tom22

    • B.

      Dime10Nickle5Quarter25 Jerry45Vickie38Tom22

    • C.

      Quarter25Dime10Nickle5 Tom22 Jerry45Vickie38

    • D.

      Error

    Correct Answer
    B. Dime10Nickle5Quarter25 Jerry45Vickie38Tom22
  • 7. 

    What is theoutput of the following Perl Code:$mystring = "Hello, am I about to be manipulated?!"; # PRINT THE ORIGINAL STRINGprint "Original String: $mystring"; $substringoffset = substr($mystring, 7);print "Offset of 7: $substringoffset";

    • 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?!

    Correct Answer
    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

    Correct Answer
    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?!
  • 9. 

    What is the output of the following Perl Code:#!/usr/bin/perl print "content-type: text/html \n\n"; #HTTP HEADER # AN ARRAY@coins = ("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

    Correct Answer
    A. Quarter Dime Nickel Penny Dollar Quarter Dime Nickel Penny
  • 10. 

    What is the output of the following perl code :#!/usr/bin/perl print "content-type: text/html \n\n"; #HTTP HEADER # SEQUENTIAL ARRAY@nums = (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

    Correct Answer
    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

    Correct Answer
    A. True
  • 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 $names"; $count++;}print "";

    • 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

    Correct Answer
    B. 1 Steve 2 Bill 3 Connor 4 Bradley
  • 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

    Correct Answer
    B. $x is equal to 7! $x or $y is equal to 7! $x and $y are equal to 7!
  • 14. 

    What is the output of the following perl code :  #!/usr/bin/perl print "content-type: text/html \n\n"; # SET A VARIABLE$count = 0;while ($count <= 7) {   if ($count == 4) {  print "Skip Four!";  next; } # PRINT THE COUNTER print $count.""; } continue {  $count++; };print "Loop Finished!";

    • 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

    Correct Answer
    A. 1 2 3 Skip Four 5 6 7 Loop Finished!
  • 15. 

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

    • A.

      True

    • B.

      False

    Correct Answer
    A. True

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Jan 22, 2013
    Quiz Edited by
    ProProfs Editorial Team
  • Dec 16, 2010
    Quiz Created by
    21centurians1
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.