wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Perl

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

In Perl, which symbol is used to indicate a scalar variable?

a)

@

b)

%

c)

$

d)

&

2.

What is the correct way to declare an array in Perl?

a)

@array = (1, 2, 3, 4);

b)

array = [1, 2, 3, 4];

c)

$array = {1, 2, 3, 4};

d)

%array = (1, 2, 3, 4);

3.

What is the default variable in Perl that stores the current topic or input?

a)

%_

b)

$_

c)

@ARGV

d)

$default

4.

Which of the following is a valid Perl loop statement?

a)

for(condition) {}

b)

foreach my $item (@array) { print $item; }

c)

loop() {}

d)

do while() {}

5.

What is the correct way to check if two scalar values are equal in Perl?

a)

if ($x = $y)

b)

if ($x == $y)

c)

if ($x eq $y)

d)

if ($x equals $y)

6.

How are string values concatenated in Perl?

a)

Using the . operator

b)

Using the + operator

c)

Using the & operator

d)

Using the , operator

7.

Which function is used to get user input from the keyboard in Perl?

a)

get()

b)

<STDIN>

c)

read()

d)

input()

8.

How do you define a function in Perl?

a)

function myFunction() { }

b)

def myFunction() { }

c)

sub myFunction { }

d)

fn myFunction() { }

9.

How do you pass parameters to a function in Perl?

a)

function(param1, param2)

b)

myFunction[param1, param2]

c)

sub myFunction { my ($param1, $param2) = @_; }

d)

def myFunction(param1, param2)

10.

What is the purpose of the return statement in a Perl function?

a)

To exit the program

b)

To return a value from a function

c)

To declare a function

d)

To call another function

11.

What is the significance of namespaces in Perl?

a)

They store large datasets

b)

They prevent naming conflicts between functions and variables

c)

They improve execution speed

d)

They convert data types

12.

How do you open a file for reading in Perl?

a)

open(FILE, "filename.txt");

b)

open my $fh, "read", "filename.txt";

c)

file_open("filename.txt", "r");

d)

open(my $fh, "<", "filename.txt");

13.

Which function is used to read a line from a file in Perl?

a)

readFile()

b)

<$fh>

c)

get()

d)

fetch()

14.

What happens if you try to open a non-existent file in Perl without error handling?

a)

Perl creates a new file

b)

Perl throws an error

c)

Perl ignores the statement

d)

The program continues execution normally

15.

In BioPerl, which module is commonly used for handling biological sequences?

a)

Bio::File

b)

Bio::Seq

c)

Bio::Search

d)

Bio::Genome