Perl Programming Language Quiz
Test your knowledge of Perl programming language syntax, operators, data structures, and built-in functions including regex patterns, array operations, hash manipulation, and string handling.
Questions
shift (@array);
- splice (@array, 0, 1);
- splice (@array, @array-1, 1);
- splice (@array, scalar(@array), 0, @sublist);
- splice (@array, 0, 0, @sublist);
pop (@array);
- splice (@array, 0, 1);
- splice (@array, @array-1, 1);
- splice (@array, scalar(@array), 0, @sublist);
- splice (@array, 0, 0, @sublist);
@array = (1,2,3); $scalar = $array[3]; print “$scalar”;
- 3
- 0
- Error:Array value out of bound
- Null value
@array = (10,30,20); sort(@array); print @array;'
- 10 20 30
- 10 30 20
- 30 20 10
- 1 2 3
. '@array = (“cat”, “rat”, “mat”); chop(@array); print @array;'
- ca ra ma
- cat rat ma
- cat rat
- cat rat mat
$string = "Hello World"; substr($string,6)="Perl"; print $string;
- Hello Perl
- Hello Perl World
- Hello
- Perl World
if(143 lt 34) { print “If is true”; } else { print “If is false”; }
- If is true
- If is false
- Error
- No output
@array = (1,2,3,4,5) $scalar1, $scalar2 = @array; print “Scalar1 value is $scalar1”; print “Scalar2 value is $scalar2”;
- 1 2
- 4 5
- 4 4
- 4 0
$scalar = (10,20,30); print $scalar;
- 10
- 20
- 30
- 3
@array = (100, 80, 70); @sort_arr = sort(@array); print @sort_arr;'
- 70 80 100
- 100 80 70
- 100 70 80
- 1 2 3
What operator is used to check whether the file is empty or not
- -e'
- -s'
- -z'
- -x'
/d[^oO]g/ matches?
- dog
- dOg
- doOg
- dig
$input = “abdce”; $output = $input =~ tr/abc/123; print $input; print $output
- 12d3e 3
- 12d3e 5
- 12d3e 1
- Error
- 12d3e null string
The purpose of ?: in this is /(?: [a-z]+/ is?
- To enclose a subpattern in parenthesis without storing it in memory.
- To define a boundary condition
- To enclose a pattern within pattern
- None of the above
Which of the following is not a predefined subroutine?
- BEGIN
- END
- DEFAULT
- AUTOLOAD
- NONE OF THE ABOVE
Which is the best way to delete an element in an associative array?
- Delete
- Push
- Pop
- Shift
- Unshift
$string = “GoodWorld”; $string =~ s/o*/i/; The value of $string is?
- iGoodWorld
- GidWirld
- GidWorld
- Gioworld
- GoodWorld
$data = “Welcome Perl” =~ /(.*)/; print $data;
- 0
- 1
- Welcome
- Perl
- Welcome Perl
my %hash = ( 'hi' => {'hello' => 'all'}, 'bye' => {'later' => 'gone'} ); print $hash{'hi'};
- hello
- 0
- hello => all
- HASH(0x??????) where ?????? is a group of hex digits.
- error
my $val = ‘x’; print ref($val);
- scalar
- any decimal value
- empty value
- x