Perl Programming and Regular Expressions

Test your knowledge of Perl programming language syntax, arrays, string manipulation, and regular expression patterns.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

my $txt = ‘I am learning Perl’; $txt =~ /(\w+)$/; print $1;

  1. I am learning Perl
  2. I
  3. Perl
  4. l
  5. learning
Question 2 Multiple Choice (Single Answer)

In perl, a/n -------------- is a special character or a sequence that will define the number of times the previous character or sequence appears.

  1. Character Class
  2. Meta character
  3. Quantifier
  4. Assertion
Question 3 Multiple Choice (Single Answer)

$input = “abdce”; $output = $input =~ s/abc/123; print $input; print $output

  1. abcde nullstring
  2. abdce 3
  3. abdce null string
  4. abdce 0
  5. abdce 1
Question 4 Multiple Choice (Single Answer)

splice(@array,-1)

  1. Equal to Pop
  2. Equal to Push
  3. Equal to Shift
  4. Equal to Unshift
  5. Does nothing
Question 5 Multiple Choice (Single Answer)

push (@array, @sublist);

  1. splice (@array, 0, 1);
  2. splice (@array, @array-1, 1);
  3. splice (@array, scalar(@array), 0, @sublist);
  4. splice (@array, 0, 0, @sublist);
Question 6 Multiple Choice (Single Answer)

unshift (@array, @sublist);

  1. splice (@array, 0, 1);
  2. splice (@array, @array-1, 1);
  3. splice (@array, scalar(@array), 0, @sublist);
  4. splice (@array, 0, 0, @sublist);
Question 7 Multiple Choice (Single Answer)

$input = "azz"; print ++$input;

  1. abc
  2. aza
  3. baa
  4. aaa
Question 8 Multiple Choice (Single Answer)

$input = 'abc'; print --$input;

  1. abc
  2. abb
  3. minus 1
  4. Error:Can perform this operation
Question 9 Multiple Choice (Single Answer)

$val = 26; $result = (++$val, $val+5); print $ result;

  1. 31
  2. 32
  3. 29
  4. 33
Question 10 Multiple Choice (Single Answer)

@array = (1,2,3,4,5) $scalar1, $scalar2 = @array; print “Scalar1 value is $scalar1”; print “Scalar2 value is $scalar2”;

  1. 1 2
  2. 4 5
  3. 5 5
  4. Null value 5
Question 11 Multiple Choice (Single Answer)

@array= (“one”,”two”,”three”,”four”,”five”); @sublength = (1,2,3); @sub_array = @array[@sublength]; print @sub_array;

  1. one two three
  2. two three four
  3. 3
  4. Error:unknown array
Question 12 Multiple Choice (Single Answer)

$input = “bc999”; print ++$input;

  1. bc999
  2. bd000
  3. bc100
  4. cd100
Question 13 Multiple Choice (Single Answer)

Perl is

  1. Compiled Language
  2. Interpretive Language
  3. Machine Language
  4. All the above
Question 14 Multiple Choice (Single Answer)

. Shifting left n bits, and right n bits, Where n is some number greater than 0 is equivalent to?

  1. Mulitplying by 2n and Dividing by 2n
  2. Dividing by 2n and Multiplying by 2n
  3. Multiplying by n and Dividing by n
  4. Dividing by n and Multiplying by n
Question 15 Multiple Choice (Single Answer)

/de{3,}/ matches

  1. deeef
  2. def
  3. deef
  4. deeeef
  5. AandD
Question 16 Multiple Choice (Single Answer)

@array = (1,2); ($scalar1, $scalar2, $scalar3)=@array; print $scalar1, $scalar2, $scalar3;

  1. 1 2 Null value
  2. 1 2 0
  3. 1 2 3
  4. Error:Array out of bound
Question 17 True/False

Is null string list (“”) equivalent to empty list()

  1. True
  2. False
Question 18 Multiple Choice (Single Answer)

Which of the followings can be a pattern delimiter

  1. $
  2. ^
  3. "
  4. %
  5. III and IV
Question 19 Multiple Choice (Single Answer)

/abc(?=def)/ matches?

  1. abc
  2. abcdef
  3. abcdefgh
  4. abcde
  5. II and III
Question 20 Multiple Choice (Single Answer)

/abc(?!def)/ matches

  1. abc
  2. abcdef
  3. abcd
  4. abdef
  5. I and III