Perl Programming

Test your knowledge of Perl programming language including functions, operators, string manipulation, arrays, hashes, subroutines, and object-oriented features.

18 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

$string = "good food"; $string =~ s/o*/e/;print $string;

  1. geod food
  2. geed food
  3. geed feed
  4. egood food
Question 2 Multiple Choice (Single Answer)

Which Operator can be used in sort function for sorting array elements numerically?

  1. <>
  2. >
  3. <=>
  4. cmp
Question 3 Multiple Choice (Single Answer)

Which variable stores the parameters passed to subroutine?

  1. $@
  2. @
  3. @_
  4. $#
Question 4 Multiple Choice (Single Answer)

To repeat the iteration of loop we will use following statement ?

  1. next
  2. repeat
  3. recall
  4. redo
Question 5 Multiple Choice (Single Answer)

In perl ,if $variable="10" then what will output of print 'this is $variable'; ?

  1. this is $10
  2. this is $variable
  3. this is
  4. this is 10
Question 6 Multiple Choice (Single Answer)

How to check version of perl on your machine ?

  1. perl -b
  2. perl -version
  3. perl -c
  4. perl -k
Question 7 Multiple Choice (Single Answer)

How to remove first element of a array?

  1. unshift
  2. delete
  3. shift
  4. move
Question 8 Multiple Choice (Single Answer)

what is output of print abs("123abc") ?

  1. 0
  2. 123
  3. abc
  4. 12
Question 9 Multiple Choice (Single Answer)

How to check if key exists in a hash or not ?

  1. exists
  2. defined
  3. undef
  4. exist
Question 10 Multiple Choice (Single Answer)

chomp(@array) will

  1. work on first eleemnt of array
  2. work on last element of array
  3. works on all elements of array
  4. wont work on array
Question 11 Multiple Choice (Single Answer)

Which function you will use to create object in perl?

  1. bless
  2. createobject
  3. create_object
  4. blessed
Question 12 Multiple Choice (Single Answer)

Which special variable actually tells perl where to look for perl modules ?

  1. %INC
  2. @INC
  3. INC
  4. %PATH%
Question 13 Multiple Choice (Single Answer)

How to length of string ?

  1. Length
  2. length
  3. len
  4. strlen
Question 14 Multiple Choice (Single Answer)

How to compile a perl program?

  1. perl -c <<programname>>
  2. perl -c
  3. You cannot compile a program
  4. perl -e <<programname>>
Question 15 Multiple Choice (Single Answer)

Which subroutine you need to define in your package if you want to handle calls to non-existing subroutines?

  1. DESTROY
  2. AUTOHANDLE
  3. AUTOLOAD
  4. AUTOLOADER
Question 16 Multiple Choice (Single Answer)

What is the name of default namespace in perl?

  1. main
  2. Main
  3. global
  4. name
Question 17 Multiple Choice (Single Answer)

Which of the following block executes at compile time?

  1. END
  2. BEGIN
  3. CHECK
  4. INIT
Question 18 Multiple Choice (Single Answer)

Which function removes last character of a string?

  1. chop
  2. chomp
  3. delete
  4. chopp