Perl Programming and Regular Expressions
Test your knowledge of Perl programming language syntax, arrays, string manipulation, and regular expression patterns.
Questions
my $txt = ‘I am learning Perl’; $txt =~ /(\w+)$/; print $1;
- I am learning Perl
- I
- Perl
- l
- learning
In perl, a/n -------------- is a special character or a sequence that will define the number of times the previous character or sequence appears.
- Character Class
- Meta character
- Quantifier
- Assertion
$input = “abdce”; $output = $input =~ s/abc/123; print $input; print $output
- abcde nullstring
- abdce 3
- abdce null string
- abdce 0
- abdce 1
splice(@array,-1)
- Equal to Pop
- Equal to Push
- Equal to Shift
- Equal to Unshift
- Does nothing
push (@array, @sublist);
- splice (@array, 0, 1);
- splice (@array, @array-1, 1);
- splice (@array, scalar(@array), 0, @sublist);
- splice (@array, 0, 0, @sublist);
unshift (@array, @sublist);
- splice (@array, 0, 1);
- splice (@array, @array-1, 1);
- splice (@array, scalar(@array), 0, @sublist);
- splice (@array, 0, 0, @sublist);
$input = "azz"; print ++$input;
- abc
- aza
- baa
- aaa
$input = 'abc'; print --$input;
- abc
- abb
- minus 1
- Error:Can perform this operation
$val = 26; $result = (++$val, $val+5); print $ result;
- 31
- 32
- 29
- 33
@array = (1,2,3,4,5) $scalar1, $scalar2 = @array; print “Scalar1 value is $scalar1”; print “Scalar2 value is $scalar2”;
- 1 2
- 4 5
- 5 5
- Null value 5
@array= (“one”,”two”,”three”,”four”,”five”); @sublength = (1,2,3); @sub_array = @array[@sublength]; print @sub_array;
- one two three
- two three four
- 3
- Error:unknown array
$input = “bc999”; print ++$input;
- bc999
- bd000
- bc100
- cd100
Perl is
- Compiled Language
- Interpretive Language
- Machine Language
- All the above
. Shifting left n bits, and right n bits, Where n is some number greater than 0 is equivalent to?
- Mulitplying by 2n and Dividing by 2n
- Dividing by 2n and Multiplying by 2n
- Multiplying by n and Dividing by n
- Dividing by n and Multiplying by n
/de{3,}/ matches
- deeef
- def
- deef
- deeeef
- AandD
@array = (1,2); ($scalar1, $scalar2, $scalar3)=@array; print $scalar1, $scalar2, $scalar3;
- 1 2 Null value
- 1 2 0
- 1 2 3
- Error:Array out of bound
Is null string list (“”) equivalent to empty list()
- True
- False
Which of the followings can be a pattern delimiter
- $
- ^
- "
- %
- III and IV
/abc(?=def)/ matches?
- abc
- abcdef
- abcdefgh
- abcde
- II and III
/abc(?!def)/ matches
- abc
- abcdef
- abcd
- abdef
- I and III