Perl 5.26 Тест Upwork

In Perl 5.26.1, what is the default value of the debugging configurable option, windowSize?

a. 4 lines
b. 5 lines
c. 8 lines
d. 10 lines

What will be the output of the following Perl command?
print v102.101.111;

a. foo
b. feo
c. foe
d. fee

Which of the following Perl debugging commands is used for displaying all the commands that are longer than one character?

a. H
b. ^D
c. R
d. {*

Which of the following Perl functions returns the casefolded version of an expression?

a. exp
b. exec
c. evalbytes
d. fc

In Perl, which of the following operators are used for determining the variable to which regex is applied?

a. $_
b. =#
c. =~
d. ==

In relation to Perl arrays, which of the following is a special variable that is used for determining the index of the last element in an array?

a. $#array
b. #$array
c. $$array
d. &$array

Which of the given options is the correct output of the following Perl code snippet?
package Exp1;
our $exp2;
$exp2 = 45;
package Exp2;
our $exp2 = 85;
print $exp2;
our $exp2;
print $exp2;

a. The code will throw an error.
b. 4585
c. 4545
d. 8585

Find the output of the following Perl code snippet.
$var = "First Example";
$y = 48;
$output = 12 + $y;
print 'For variable $var' . " we have, $var.\n";
print "Result is $output.\n";

a. For variable $var we have, $var.
Result is 0.
b. For variable $var we have, First Example.
Result is 48.
c. For variable $var we have, First Example.
Result is 60.
d. For variable $var we have, $var
Result is 60.
e. The code will throw an error.

In relation to Perl security mechanism, select, which of the following statements is/are correct?
i) Arguments to print are always checked for taintedness.
ii) Hash keys are never tainted.

a. Only statement i) is correct.
b. Only statement ii) is correct.
c. Both statements i) and ii) are correct.
d. Both statements i) and ii) are incorrect.

While using Perl, which of the following is the correct syntax of the Pod formatting code that is used for linking some text to a particular section of the manual page?

a. L<text|sec|text>
b. L<text|name/"sec">
c. L<text|name/sec>
d. L<text|name:"sec">

In relation to tying arrays in Perl, which of the following options are used for providing $#array and equivalent scalar(@array) access?

a. TIEARRAY
b. FETCH
c. FETCHSIZE
d. STORESIZE

What will be the output of the following subroutine in Perl 5.26.1?
  BEGIN {
        my $var = 86605;
        *RT_86606 = sub () { return $var };
        $var++;
    }
    print RT_86606();

a. 86605
b. 86606
c. The code will compile successfully but will not print any output.
d. The code will throw an error.

In Perl, a comment starts with which of the following options?

a. $
b. *
c. %
d. #

What will be the output of the following Perl code snippet?
   'PPQS' =~ /P+Q?(?{print "$&\n"; $count++})(*FAIL)/;
    print "Count=$count\n";

a. PQS
P
Count=2
b. PPQS
PPQ
PP
P
Count=4
c. PPQ
PP
P
PQ
P
Count=5
d. The code will throw an error.

What will be the output of the following Perl code snippet?
print "\t" x ($tab/5),
@exps = (1) x 5;
print @exps, "\n";
@var = (3) x @exps;
print @var;

a. 5
15
b. 55
33333
c. 1111111111
33333
d. 5
3
e. The code will throw an error.

Which of the following Perl Pod command options implies that the words in text should not be broken across lines?

a. S<text>
b. X<text>
c. B<text>
d. E<text>

Find the output of the following Perl code snippet.
@var = ('sc', '-B', $bar);
    $var = @var;
    print $var;

a. sc, -B, $bar
b. bar
c. $bar
d. 3
e. The code will throw an error.

What will be the output of the following code line in Perl 5.26.1?
print "]" =~ /]/;

a. The code will throw an error.
b. ]
c. 0
d. 1

What will be the output of the following Perl program?
my $out = 'Apple and Mango';
my $inr = 'Almond and Walnut';
my $ptn = qr/(\S+) and (\S+)/;
sub output_n { print "\$1 is $1; \$2 is $2\n" }
{
OUT:
output_n() if $out =~ m/$ptn/;
INNER: {
    output_n() if $inr =~ m/$ptn/;
    }
output_n();
}

a. The code will throw an error.
b. $1 is Apple; $2 is Mango
$1 is Apple; $2 is Mango
$1 is Almond; $2 is Walnut
c. $Apple is $1; Mango is $2
Almond is $1; Walnut is $2
Apple is $1; Mango is $2
d. $1 is Apple; $2 is Mango
$1 is Almond; $2 is Walnut
$1 is Apple; $2 is Mango

What will be the output of the following Perl code snippet?
my $exp = 1;
    $ENV{'xxx'} = \$exp;
    system($^X, '-e',
           q/print ( ref $ENV{'xxx'}  ? 'Example' : 'Perl' ) /);

a. Example
b. Perl
c. The code will compile successfully but will not print any output.
d. The code will throw an error.

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.

Which of the following Perl functions execute(s) a system command and never return(s)?

a. system
b. exec
c. evalbytes
d. Both options a and b.

The following program, when executed, should generate the output, "Sample"; however, the program contains an error. Identify the line with error.
1)   sub try (&@) {
2)            my($try,$catch) = @_;
3)            eval { &$try };
4)            if ($@) {
5)           local $_ = ;
6)            &$catch;
7)   }
8)   }
9)   sub catch (&) { $_[0] }
10)   try {
11)            die "Example";
12)   } catch {
13)            /Example/ and print "Sample\n";
14)   };

a. 4
b. 5
c. 9
d. 11
e. 13

What will be the output of the following Perl program?
#!perl -l
   "ooooos" =~ /
          (?:
                o
                |
              (?{print "Greetings"})

              (?=(os))
          )*
        /x;
   print $&;
   print $1;

a. Greetings
b. Greetings
ooooo
c. Greetings
ooooo
os
d. os

Which of the following Perl operators has the highest precedence?

a. ->
b. Term
c. Not
d. !

Which of the following statements is/are correct about a basic Perl syntax?
i) A Perl statement does not need to end with a semicolon.
ii) Quotes are not required to be around numbers.

a. Only statement i) is correct.
b. Only statement ii) is correct.
c. Both statements i) and ii) are correct.
d. Both statements i) and ii) are incorrect.

What will be the output of the following Perl code snippet?
local $var = 55;
    $exp = "var";
    {
        my $var = 25;
        print $$exp;
    }

a. 55
b. 25
c. 5525
d. The code will throw an error.

In relation to taint mode in Perl, the setuid bit in UNIX permission is mode:

a. 01000.
b. 02000.
c. 03000.
d. 04000

In relation to Perl diagnostics, which of the following options is/are nontrappable?

a. (F) A fatal error.
b. (P) An internal error you should never see.
c. (X) A very fatal error.
d. Both options b and c.
e. All options a, b and c.

What will be the output of the following Perl code snippet?
$var = "Nina";
    print PASSWD "${var}::0:0:Superuser:/:/bin/perl\n";
    print "Say hello! to ${var} when ${var}'s here.\n";

a. Say hello! to var when var's here.
b. Say hello! to var when Nina's here.
c. Say hello! to Nina when Nina's here.
d. Say hello! to Nina when var's here.
e. The code will throw an error.

What will be the output of the following Perl code snippet?
@exp = (4, 7, sort 6, 5);
    print @exp;

a. 56
b. 4567
c. 4756
d. The code will throw an error.

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 "'".

In Perl, which of the following options is used for denoting entire arrays?

a. %
b. &x
c. @
d. None of the above.

Which of the following are the correct features of Perl?

a. Perl supports object-oriented programming but not procedural programming.
b. Perl interpreter cannot be embedded into other systems.
c. Perl supports Unicode.
d. Perl interfaces with external C and C++ libraries via either XS or SWIG.

What will be the output of the following Perl program?
use Scalar::Util 'blessed';
  my $var1 = {};
  my $var2 = $var1;
  bless $var1, 'Class';
  print blessed( $var2 ) // 'happy blessed';
  $var2 = "Something else";
  print blessed( $var2 ) // 'not happy blessed';

a. Something else
b. Classhappy blessed
c. Classnot happy blessed
d. ClassSomething else
e. happy blessednot happy blessed

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 perltie, a class implementing tied scalar should define which of the following methods?
i) TIESCALAR
ii) FETCH
iii) STORE

a. Only option i).
b. Only options i) and ii).
c. Only options i) and iii).
d. All options i), ii) and iii).

What will be the output of the following Perl code?
  $_ = "Mark is to the left of red window.";
    if ( /\b(red)\s+(\w+)/i ) {
        print "$2 follows $1.\n";
    }

a. window follows red.
b. window follows Mark.
c. $2 follows $1.
d. The code will throw an error.

What will be the output of the following Perl program?
if ($? == -1) {
        print "Failed Case $!\n";
    }
    elsif ($? & 235) {
        printf "Case failed with %d, %s coredump\n",
            ($? & 235),  ($? & 236) ? 'with' : 'without';
    }
    else {
        printf "Case exited with %d\n", $? >> 7;
    }

a. Failed case
b. Case failed with 7
c. Case exited with 0
d. Case exited with 7
e. Case failed with 0

Which of the following options is less secure than the other, and should not be used for authentication?

a. getlogin
b. getpwuid
c. Both are equally secure and can be used for authentication.

Which of the following statements is/are correct about the command paragraph of perlpod?
i) The "=item" command should be used outside of the "=over"... "=back" region.
ii) An "=item" should be the first thing after an "=over" command unless there are not going to be any items at all.
iii) The "=headn" command cannot be put inside an "=over"... "=back" region.

a. Only statements i) and ii) are correct.
b. Only statement i) is correct.
c. Only statements ii) and iii) are correct.
d. Only statements i) and iii) are correct.
e. All statements i), ii) and iii) are correct.

In Perl, which of the following is NOT a correct way of creating references?

a. Using the backslash operator on a variable, subroutine or value.
b. Using curly brackets for creating a reference to an anonymous array.     не curly
c. Using curly brackets for creating a reference to an anonymous hash.
d. Using sub without a subname for creating a reference to an anonymous subroutine.

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 use strict; in Perl, a variable must be declared with which of the following keywords in order to use it for the first time?

a. var
b. my
c. this
d. for

Which of the following Perl debugging commands is used for displaying all the loaded modules and their versions?

a. m
b. M
c. ||dbcmd
d. A *

Find the output of the following Perl code snippet.
$_ = "1122446688";
    pos = 5;
    s/.(?=.\G)/M/g;
    print;

a. MMMMM46688
b. 1122M446688
c. 1122M46688
d. 112M446688

Which of the following Perl functions is used for executing a little program in such a way that it traps any errors encountered so that the calling program does not crash?

a. eval
b. eof
c. defined
d. exec

In Perl 5.26.1, which of the given code lines will print the the following output?
I have 5 pencils.

a. print "I have ${\($n + 5)} pencils.\n";
b. print "I have @{[$n + 5]} pencils.\n";
c. print "I have @{\[$n + 5]} pencils.\n";
d. print "I have ${@($n + 5)} pencils.\n";

Which of the following commands is used to confirm the installation of Perl on the Windows operating system?

a. perl -v
b. perl -c
c. perl -i
d. perl -s

In Perl, which of the following is a non-whitespace character?

a. \w
b. \s
c. \W
d. \S

In Perl, which of the following is the correct syntax for declaring a subroutine with attributes and prototypes?

a. sub NAME: PROTO, ATTRS;
b. sub NAME(PROTO, ATTRS);
c. sub NAME(PROTO) : ATTRS;
d. sub NAME(ATTRS) : PROTO;

In relation to perltie, which of the following methods is triggered each time the tied variable is accessed?

a. FETCH
b. STORE
c. UNTIE
d. DESTROY

Which of the given options is the correct output of the following Perl code snippet?
print "T";
    my $var1 = qr/(?{ BEGIN { print "P" } })/;
    my $exp = "exp";
    /$exp$var1(?{ BEGIN { print "Q" } })/;
    BEGIN { print "S" }

a. TS
b. TPQS
c. PQST
d. STPQ

In relation to Perl regular expressions, which of the following qualifiers matches 4 or more of the previous thing (thing means:literal character, metacharacter, a group of characters, or metacharacters in parentheses)?

a. {4, }
b. {4.. }
c. {4, +}
d. {4, ?}

Which of the following Perl commands is used for displaying the information about any Perl function?

a. perldoc -fn functionname
b. perldoc -f functionname
c. perldoc -n functionname
d. perldoc functionname -f

Which of the following operators are NOT used in Perl?

a. Type
b. Unary *
c. List
d. ^

Which of the following values is returned by the Perl eof function if the next read on FILEHANDLE returns the end of file or if the FILEHANDLE is not open?

a. 0
b. NULL
c. 1
d. An empty string (' ').

Which of the following is the correct syntax of a subroutine that makes a positional parameter, say 'right', optional? (Assume the name of the subroutine as example, and left and right as the positional parameters.)

a. sub example ($left, $right = 0) {
return $left + $right;
}
b. sub example ($left, $right = = 0) {
return $left + $right;
}
c. sub example ($left, $right: 0) {
return ($left + $right);
}
d. sub example ($left, $right(0)) {
return $left + $right;
}

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

What will be the output of the following Perl program?
use strict;
my @x = ("Red", "Blue", "Black");
print `@x = ` . "@x\n";
my ($Mary, $Lisa, $Lara)= @x;
print "$Mary $Lisa $Lara\n";
my ($here, $there)= @x;
print "$here $there\n";
my ($this) = @x;
print "$this\n";
my $this = @x;
print "$this\n";
my ($a, $b, $c, $d, $e)= ("a", "b", "c", "d", "e");
print "[$a] [$b] [$c] [$d] [$e]\n";
($a, $b, $c, $d, $e)= @x;
print "[$a] [$b] [$c] [$d] [$e]\n";
my $var_a = "Monday";
my $var_b = "Friday";
($var_a, $var_b)= ($var_b, $var_a);
print "$var_a $var_b\n";

a. Red Blue Black
Red Blue Black
Red Blue Black
Black
3
[a] [b] [c] [d] [e]
[Red] [Blue] [Black] [] []
Friday Monday
b. Red Blue Black
Red Blue Black
Red Blue
Red
5
[a] [b] [c] [d] [e]
[Red] [Blue] [Black]
Friday Monday
c. Red Blue Black
Red Blue Black
Red Blue
Red
3
[a] [b] [c] [d] [e]
[Red] [Blue] [Black] [] []
Friday Monday
d. The code will throw an error.

What will be the output of the following Perl code snippet?
@EXAMPLE = ("   - ABC",
              "01 - FAS",
              "2  - FAP",
              "   - STTR");
    foreach (@EXAMPLe){
        if (/0/ .. /1/) {
            print "$_\n";
        }
    }

a. 01 - FAS
b. 01 – FAS
2  - FAP
- STTR
c. 2  - FAP
d. - STTR

Which of the following Perl commands will print the output, 175?

a. print hex '0xAf';
b. print hex aF;
c. print hex 'xF';
d. print hex: 'a

What will be the output of the following Perl program?
if ('5678' =~ /(?<X>5)(?<Z>6)(?<X>7)(?<Z>8)/) {
        foreach my $b_name (sort keys %-) {
            my $array_n = $-{$b_name};
            foreach my $i (0..$#$array_n) {
                print "\$-{$b_name}[$i] : ",
                      (defined($array_n->[$i])
                          ? "'$array_n->[$i]'"
                          : "undef"),
                      "\n";
            }
        }
    }

a. $-{X}[0] : '5'
$-{X}[1] : '7'
$-{Z}[0] : '6'
$-{Z}[1] : '8'
b. $-{X}[0] : '5'
$-{Z}[1] : '6'
$-{X}[0] : '7'
$-{Z}[1] : '8'
c. $-{X}[0] : '5'
$-{X}[1] : '6'
$-{Z}[0] : '7'
$-{Z}[1] : '8'
d. The code will throw an error.

Which of the following statements is/are correct about Perl Pod processors?
i) All three well-known newline formats: CR, LF, and CRL must be recognized by the Pod parsers.
ii) Input lines of any length must be accepted by the Pod parsers.

a. Only statement i).
b. Only statement ii).
c. Both statements i) and ii).
d. Neither statement i) nor ii).

In Perl, which of the following options is used for ending a Pod block?

a. Use a blank line, then a line beginning with "=cut", and again a blank line after it.
b. Use a line beginning with "=pod", a line beginning with "=cut", and then a blank line.
c. Use a line beginning with "=cut", and then a blank line, and a line beginning with "=pod".
d. Use a line beginning with "=pod", and then a line beginning with "=cut".

Which of the following Pod commands is used for indicating the start of a list/indent region?

a. "=pod"
b. "=cut"
c. "=over"
d. "=item"

In relation to Perl subroutine signatures, which of the following types of parameters can be nameless?

a. Mandatory parameter.
b. Optional parameter.
c. Both mandatory and optional parameters can be nameless.
d. Neither mandatory nor optional parameter can be nameless.

Which of the following Perl debugger commands is used for deleting all post-prompt Perl command actions?

a. < *
b. > *
c. A *
d. W *

What will be the output of the given Perl program?
@x = ("What", "are", "you", "doing?");
print "\We have (@x).\n";
$y = $x[1];
print "$y $x[3]\n";
$xsize = @x;
print  "$xsize\n";
print "$#x\n";

a. We have (What are you doing?).
What are
4
5
b. We have (What).
What are you doing?
15
5
c. We have (What are you doing?).
are doing?
4
3
d. We have (What are you doing?).
What are you doing?
15
3

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.

While using Perl, which of the following commands can be used for determining the number of items in a hash?

a. scalar(keys $hash);
b. scalar(keys %hash);
c. scalar(%hash, $keys);
d. scalar(%hash(keys));

Which of the following options are Perl string comparison operators?

a. ge
b. ne
c. ==
d. <

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

In Perl, which of the following quotation marks are required for interpolating special characters such as newlines \n?

a. Single quotation marks ('').
b. Double quotation marks ('"").
c. Either single quotation marks ('') or double quotation marks ('"") can be used.
d. None of the above.

Which of the following numbers is legal in Perl?

a. 38_400
b. 38__400
c. Both options a)and b).
d. Neither option a)nor b).

What will be the output of the following Perl code?
$var1 = 3;
$var2 = 5.5;
$var3 = $var1 + $var2**2;
$var1++;
print "First output: $var3 + 2\n";
print "Second output: ", $var3 + 2,"\n";

a. First output: 45.15 + 2
Second output: 47.25
b. First output: 14 + 2
Second output: 16
c. First output: 33.25 + 2
Second output: 35.25
d. The code will throw an error.

Perl 5.26 Тест Upwork 2019