Perl 5.26 Test

Perl 5.26 Test

 

Which of the following is the correct Pod formatting code syntax?

a. It starts with a capital letter followed by a “<” then any number of characters and ending with a matching “>”.
b. It starts with a “<” followed by a capital letter then any number of characters and ending with a matching “>”.
c. It starts with a capital letter followed by a “‘” then any number of characters and ending with a matching closing “‘”.
d. It starts with a “‘” followed by a capital letter then any number of characters and ending with a matching closing “‘”.


What will be the output of the following Perl program?

strict;
sub example {
@_ % 2 == 0 or
die “example: Ends\n”;

my %ps = ( ‘string’ => ‘Perl’,
‘between’ => ”,
‘repeat’ => 1,
‘cascade’ => 0,
‘blankafter’ => 1,
@_);

my $str = substr($ps{‘string’}, 1);
$str =~ s/(.)/$ps{‘between’}$1/g;
$str = substr($ps{‘string’}, 0, 1) . $str;
my $p = 0;
for(my $n = $ps{‘repeat’}; $n–; ) {
print ((‘ ‘ x $p), “$str\n”);
$p += $ps{‘cascade’};
}
print if $ps{‘blankafter’};
}
example;
example(repeat => 2, string => ‘EXAMPLE’, cascade => 2);
example(between => ‘ ‘);
example(between => ‘==’, repeat => 3);
example(string => ‘END!!’, blankafter => 0);

a. Perl
    EXAMPLE
    EXAMPLE
    P==e==r==l
    P==e==r==l
    P==e==r==l
    END!!
b. Perl
    EXAMPLE
    EXAMPLE
    P e r l
    P==e==r==l
    P==e==r==l
    P==e==r==l
    END!!
c. Perl
    EXAMPLE
    P e r l
    P e r l
    P==e==r==l
    P==e==r==l
    P==e==r==l
    END!!
d. The code will throw an error.


What will be the output of the following Perl program?

sub myExample {
my $a = shift;
return sub { my $b = shift; print “$a, $b!\n”; };
}
$var1 = myExample(“Mango”);
$var2 = myExample(“Fruit”);
&$var1(“Potato”);
&$var2(“Vegetable”);

a. Mango, Potato!
    Fruit, Vegetable!
b. Mango, Fruit!
    Potato, Vegetable!
c. Mango! Vegetable!
    Potato! Fruit!,
d. The code will throw an error.


In relation to identifier parsing in Perl, which of the following options is invalid?

a. $’exp
b. $exp’nap’
c. $exp’nap
d. All of the above are valid.


In relation to Perl taint mode and @INC, which of the following command line options is used for adjusting @INC from outside the program?

a. -I
b. -wU
c. -E
d. -a


What will be the output of the following Perl program?

use strict;

sub sent
{ my $s = shift @_;
my $v = shift @_;
my $aj = shift @_;
my $oj = shift @_;

print uc(substr($s,0,1)), substr($s,1), ” $v the $aj $oj.\n”;
}
my $exp;
sub changexp
{
my $first = shift @_;
$first = ‘cold’;
$_[0] = ‘warm’;
$exp = 40;
}

sent(‘Mia’, ‘likes’, ‘pink’, ‘dress’);
sent(‘Mark’, ‘dislikes’, ‘green’, ‘tea’);

$exp = 80;
my ($a, $b)= (‘January’, ‘May’);
print “\n$exp $a $b\n”;
changexp($a, $b);
print “$exp $a $b\n”;

a. Mia likes the pink dress.
    Mark dislikes the green tea.
    80 January May
    40 January warm
b. Mia likes the pink dress.
    Mark dislikes the green tea.
    80 January cold
    40 January warm
c. Mia the likes pink dress.
    Mark the dislikes green tea.
    80 January
    40 January warm
d. Mia likes pink dress.
    Mark dislikes the green tea.
    80 January cold
    40 January


In relation to the Perl regular expression, which of the following modifiers is used for performing case-insensitive pattern matching?

a. m
b. i
c. x
d. p


What will be the output of the following Perl code snippet?

print (3+4)+5;
print “\n”, +(3+4)+5;

a. 12
    12
b. 12
    7
c. 7
    12
d. 7
    7
e. The code will throw an error.


Prev1 of 5

Share This Post