
Q91
Q91 Why might sorting a hash using sort %hash cause unexpected results?
Hashes are unordered
Sort cannot be used on hashes
Sort only works on arrays
Hashes must be converted to arrays first
Q92
Q92 What keyword is used to import a Perl module?
import
use
require
include
Q93
Q93 What is the purpose of the require function in Perl?
Loads a module at compile time
Loads a module at runtime
Defines a package
Removes a module
Q94
Q94 What is the difference between use and require in Perl?
use loads at runtime, require loads at compile time
Both load modules at runtime
use loads at compile time, require loads at runtime
require can only be used for built-in modules
Q95
Q95 What is the purpose of the @INC array in Perl?
Stores imported variables
Contains paths to module directories
Defines function names
Lists all installed modules
Q96
Q96 How do you define a package in Perl?
package ModuleName;
module ModuleName;
define ModuleName;
include ModuleName;
Q97
Q97 What does the following Perl statement do?
use strict;
Enables strict mode for variable declarations
Turns off warnings
Defines a new package
Includes external modules
Q98
Q98 What is the purpose of Exporter in Perl modules?
Allows functions to be exported from a module
Defines private functions
Deletes functions from a module
Restricts module access
Q99
Q99 How do you correctly define and export a function in a Perl module?
our @EXPORT = ('function_name');
export function_name();
import function_name();
define function_name();
Q100
Q100 What is the correct way to include a module from a custom path?
use lib '/path/to/module';
require '/path/to/module';
include '/path/to/module';
import '/path/to/module';
Q101
Q101 Why might a Perl script fail with "Can't locate module in @INC"?
The module does not exist
The module is in an unlisted directory
Incorrect function usage
The module is already loaded
Q102
Q102 Why does use MyModule; sometimes fail even if the module exists?
The module is not compiled
The module does not have a .pm extension
The module does not return a true value
The module is too large
Q103
Q103 What might cause require to fail when loading a module?
The module is already in memory
The module lacks a valid package declaration
The module is case-sensitive in filename
Perl does not support require
Q104
Q104 What keyword is used to define a class in Perl?
class
package
module
object
Q105
Q105 How is an object typically created in Perl?
new ClassName;
ClassName->new();
create ClassName();
ClassName->create();
Q106
Q106 What is the significance of the bless function in Perl?
It converts a scalar into an object
It loads a module
It creates a new package
It deletes an object
Q107
Q107 How does Perl support inheritance in object-oriented programming?
Using extends
Using @ISA array
Using super
Using inherit
Q108
Q108 What does the following Perl code do?
sub new { my $class = shift; my $self = {}; bless $self, $class; return $self; }
Creates a new function
Defines a constructor for an object
Creates a hash
Declares a global variable
Q109
Q109 How do you call a method on an object in Perl?
$object->method();
method($object);
$object.method();
call method on $object;
Q110
Q110 What does @ISA = ('ParentClass'); do in a Perl package?
Defines an object
Declares an array
Specifies class inheritance
Creates a new method
Q111
Q111 Why does calling $object->method(); result in an error?
The method does not exist
Perl does not support methods
The object is not blessed
Perl requires an explicit import
Q112
Q112 What is a common mistake when defining a constructor in Perl?
Forgetting to bless the object
Using new instead of construct
Returning a hash instead of a scalar
Declaring methods inside the constructor
Q113
Q113 What does the warn function do in Perl?
Terminates execution
Prints a warning but continues execution
Ignores errors
Restarts the script
Q114
Q114 How does the eval function help in error handling?
Stops execution on an error
Executes code and captures errors
Logs errors to a file
Raises exceptions only for syntax errors
Q115
Q115 What does $@ contain after an eval block?
The last evaluated value
The last error message
The function return value
The script's execution time
Q116
Q116 What is the purpose of local $SIG{DIE}?
Handles fatal errors
Ignores all errors
Displays warnings only
Restarts the script on failure
Q117
Q117 What will happen when the following Perl code runs?
eval { die "Error occurred"; }; print "After eval";
Script terminates
Prints "After eval"
Throws an error
Ignores the die statement
Q118
Q118 What will be the output of eval { 1 / 0 }; print $@;?
0
Infinity
Division by zero error message
Syntax error
Q119
Q119 How do you suppress Perl errors without terminating the script?
use strict;
use eval;
eval { };
catch { };
Q120
Q120 Why does die "Error" sometimes fail to stop execution?
die does not work in Perl
The script is inside an eval block
Errors require warn
Perl does not handle fatal errors