Perl MCQ Questions and Answers
Perl Questions and Answers contain set of 10 Perl MCQ questions with answers which will help you to clear beginner level Perl quiz.
1. The statement open(FH,”abc.txt”) will :
- Opens the file abc.txt for overwriting.
- Opens the file abc.txt for reading.
- Contains an error, so won’t compile.
- Opens the file abc.txt for appending.
2. Which of the following is used in perl?
- elseif
- else if
- elsif
- else-if
3. What will be printed by the code below :
my $val = {};
print ref($val);
- Array value
- Hash value
- Scalar value
- Empty value
4. What will be printed in the below code :
my @array = (0,1,2);
my $val = @array;
print “$val”;
- 0 1 2
- 0
- 3
- Error code
5. In Perl, scalar variables always start with a __________.
- %
- #
- $
- @
6. In Perl, the words function and subroutines are used interchangeably.
- True
- False
7. What gets printed for the code :
my $string = ‘a\\b\n’;
print $str;
- a\\b\n
- ab (newline)
- a\b\n
- a\\b (newline)
8. What will be printed :
print ‘a’;
BEGIN {
print ‘b’;
}
sub foo {
print ‘c’;
}
- abc
- bca
- ba
- ab
9. Which of the following special variable is not related to regular expression matches?
- $_
- $’
- $&
- $`
10. The argument ‘-d’ in Perl stands for debug.
- True
- False