Find Interview Questions for Top Companies
Ques:- package MYCALC; use Exporter; our @EXPORT = (); our @ISA = qw(Exporter); our @EXPORT_OK = qw(addition multi); our %EXPORT_TAGS = (DEFAULT => [qw(&addition)],Both => [qw(&addition & +multi)]); sub addition { return $_[0] + $_[1]; } sub multi { return $_[0] * $_[1]; } 1; Program: use strict; use warnings; my @list = qw (2 2); use Module qw(:DEFAULT); print addition(@list),”n”; Above coding is my module MYCALC and the program which using this module, I have not exported any function using @EXPORT, but I have used the DEFAULT in %EXPORT_TAGS with the function addition, when I call this function from the main it says the error as,
Asked In :-
Ques:- What is the difference between $array[1] and @array[1]?
Asked In :-
Comments
Admin May 17, 2020

$array[1] represents a scalar value.
@array[1] represents array slicing.
@array[1] returns a list with one scalar value.
We should use $ when we want a scalar value.
If we want a list we need to use @.
If we use 'use warnings' then @array[1] will give the warnings
like ,Scalar value @array[1] better written as $array[1].

Ques:- How can I implement the function overloading in Perl ? I read about the operator overloading, I do not know how to implement the function overloading. Thanks in advance ?
Asked In :-
Ques:- my @array=(‘data1′,’data2’); my @array1=(‘data1′,’data2’); my ($i,$k); $i=7; $k=7; while($i){ $array [++$#array] = ‘ree’; $i–; print “@array”; } while($k){ push(@array1,’ree’); $k–; print “@array1”; } Are these two while loop are doing the same functionality ? What may be the difference?
Asked In :-
Comments
Admin May 17, 2020

The above two while loops are used to add the elements into
the end of the array.
But in first while loop we are manually getting the index of
the last element in the array then we are storing the
element into next index.
But push internally performing that operation.
And the push() has some advantages also.
Using push we can add multiple items into an array in a
single instance.
But this is not possible in the fist while loop.

Ques:- what is the difference between require and use in perl?
Asked In :-
Comments
Admin May 17, 2020

use:
* Object Verification will happen @ Compile Time.
* File will have extention of .pm
* Module location will be set by @ISA Variable.
require:
* Object Verification will happen @ Run TIme.
* Method can be used from and .pm or .pl file.
* Absolute path to be given, if file located in different
dir.

Admin May 17, 2020

use:
1-its compile time concept & refresh the namespace for
different package loading.
Require:
it is run time concept & does not refresh the namespace for
different package loading.

Ques:- what is the difference b/w coldfusion MX 6 and Coldfusion MX 7?
Asked In :-
Comments
Admin May 17, 2020

Windows authentication introduced
thorough "cfntauthenticate" tag
cfcompile utility introduced which used for Sourceless
deployment
Administrator API: Change ColdFusion settings
programmatically, without logging into the CF Administrator.
Gateways: SMS, IM (based on Extensible Messaging and
Presence Protocol) gateways introduced

Ques:- Which web site will help the student to download the Java mini Project ?
Asked In :-
Comments
Admin May 17, 2020

123eng.com,File guru.com

Ques:- while(my($key, $value) = each(%hash) ) { print “$key => $valuen”; } my($key, $value); while(($key, $value) = each(%hash) ) { print “$key => $valuen”; } What is the different between these two code in case of “my” usage ?
Asked In :-
Comments
Admin May 17, 2020

case 1:
by decalring "my" we are making the variable local.
So you cant access the value of those variable from the
outsite of that block.
case 2:
here you can access the value of the code from the
outside of that code.
"my" is generally used to protect the variable from
mingling.

Ques:- how to install a package in perl ????
Asked In :-
Comments
Admin May 17, 2020

Perl Installation on Linux/Unix:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% perl Makefile.PL
% make // nmake for Windows.
% make test
% make install
% make clean
Perl Installation on Windows:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% perl -MCPAN -e shell
% install <Module Name> Eg: install Net::FTP

Admin May 17, 2020

doing make test and doing install <mod name> is only
possible if you are a root user or a trusted su user,
otherwise it is not at all possible to install the module in
perl.
but if you want to use that module without actually
installing it, it is possible. first download the tar file
of the module from the CPAN then untar the file in your
desired directory then see that where the .pm file lies copy
that .pm file to your desired location. now you have to see
whether that module is further using any module or not if
not then it is fine but if then you have to do the entire
process for the new module and provide the customized path
to the first module in the use or require, include the
desired pm file as using require lib or pushing the pm at
@INC manually.
push @INC <path to module>;

Ques:- How to count no of occurrence of a unique patterns in perl?
Asked In :-
Comments
Admin May 17, 2020

if we are looking for occurrences of single character in a
string then we can use TR command
syntax: tr///
example:
$string="The lion group will meet me after lunch";
and we are looking for the occurrences of character 'l' in
the given string. then we can write tr like
$count = ($string=~tr/l//);
print "l is coming $count time(s)";
but for multiple characters look up we have to use:
$string = "-9 55 48 -2 23 -76 4 14 -44";
while ($string =~ /-d+/g) { $count++ }
print "There are $count negative numbers in the string";
Donated by :- Kuldip singh behal

Admin May 17, 2020

while ($string =~ /<pattern>/g) { $count++ }

Ques:- how to search a unique pattern in a file by using perl hash map function ??? plz answer me
Asked In :-
Comments
Admin May 17, 2020

I did't got ur answer ..!!
Can u explain it a lil Bit ...

Admin May 17, 2020

open(FH, "file");
@array = <FH>;
%seen = ();
@uniq = grep{!seen{$_}++} @array;

Ques:- How do you debug a Perl scripting ( at the compile time error or run time error) in Unix environment ?
Asked In :-
Comments
Admin May 17, 2020

we can also use -c and -d switches to debug our perl scripts
ex:
perl -c sample.pl (for compilation errors)
perl -d sample.pl (for debugging the code line by line)

Admin May 17, 2020

For debugging perl scripting u can use
1. diagnostic modules - which can help us isolate and
understand problems with our code.
EX- use warning, use strict, use diagnostics
2.perl command line switches - u can create test programm
using the perl command line.
Ex-i) #!user/bin/perl -w
or on the command line like this
>perl -w program.plx
ii) -e = it tells the perl not to load and run a program
file but to run the text following -e as a program.
> perl -e "print "hello World n";"
iii)-c = stops perl from running your program instead ,al it
does is check that code can be complied as valid perl.
its a good way to quickly check that a program has no
glaring syntax errors.
> perl -ce 'print "hello,worldn";'
and so on it will available Google u can search ........
3. debugging techniques and perl de-debugger - how to remove
the problems that we've found.
Using debugger
> perl -d filename.plx

Ques:- what r the different type of function in perl ???
Asked In :-
Ques:- How can you create an object of a class in a package?
Asked In :- High Peak Software,
Comments
Admin May 17, 2020

package Test;
sub new
{
$class = shift;
$self = {};
bless $self,$class; # By Mistake earlier i wrote it as
#$ref
return $self;
}
1;
# In perl Script
use Test; # Include the module you have created
$obj=new Test; # creating an onject of Class Test

Admin May 17, 2020

Say Pachage is My Package
package MyPackage;
sub method() {
}
Then U can create Object
$myobject = new MyPackage();
and u can call any method of object like:
$myobject->method();

Ques:- what is the procedure to define a user define module in your perl application?
Asked In :-
Comments
Admin May 17, 2020

Create a .pm file eg xyz.pm and you can have subroutines or
what ever you want can be placed there.
#content of xyz.pm
package xyz;
sub Printit{
print "In module xyz...";
}
1;
#end of xyz.pm
for using this perl module in ur perl program eg abc.pl
# content of abc.pl
use xyz;
xyz->Printit();
#end pf abc.pl
hope this helps :)

Admin May 17, 2020

Package Module_name;
require Exporter;
@ISA = qw(list of base classes);
@Export = qw(list of symbols );
#------------code---------------------
#at the end of module
1;

Ques:- How would you trap error occurred in the perl program/file?
Asked In :-
Comments
Admin May 17, 2020

You can catch the errros by using eval function.
Keep your code in eval block some thing like shown below.
Eg.,
#################################
eval {
my $a = 0;
my $b = $a/0; #Dividing 0 with 0 is definitely an error
};
if ($@) {
print "n Error in your code";
}
############################
-> Eval block always ends with a semi-colon. $@ will catch
the errors persent.
-> If any errors are present $@ will be set otherwise $@
will not be set
-> Unfortunately in Perl we don't have Explicit Error
handling techniques like some other languages like java etc
I mean like IOException etc.,

Admin May 17, 2020

#Ist trapping the error in a block
eval {
# perl code goes here
};
if ($@) { # $@ is a special variable containing the error
if any else blank
print "Print your own error If u want";
}
# 2nd
# use if or unless for a loop ;ike below
if(chk some condition)
{
die"$!n"; # if the condition success
}
system generated error is printed and the scirpt is exited
}

Ques:- Can any1 tell me 2 write the script using perl script 2 looking at a log file 2 see wheather the test has passed or not.
Asked In :-
Comments
Admin May 17, 2020

The question is not clear, if i am picking you up
correctly, here is the answer.
If you want to check the particular part of a code ran fine
or not,you can put it in a eval block and then check for $@
(if $@ set, something wrong) and accordingly print the
message in the log file.
If not helpful,can you pls explain the questions properly.

Admin May 17, 2020

Could you pelase let me know how to justified the test is
pass or not.

Ques:- What is the difference between module and package?
Asked In :-
Comments
Admin May 17, 2020

- A module is a .pm file containing some Perl code.
- A package is a declaration of the name of the current
scope, e.g.:
package Math::Complex
- Which can occur in the code of a module or a script.
- A module can be used, because it is a physical
'thing', but a package cannot.
- A module may contain several packages:

Admin May 17, 2020

Modules and packages are usually used interchangeably. But
there is a difference.
a. Packages are perl files with .pm extn and is considered
a separate namespace. So a package is nothing but group of
related scalars,arrays,hashes and subroutines for a
specific purpose.Once a package is included in a .plx file
(using "use") and you want to call one of the subroutines
of the package, you may have to use the scope resolution
operator &package::subroutine1 ( as the subroutine of the
package is in a separate name space).
b. Modules are packages but which has the capabilities of
exporting selective subroutines/scalars/arrays/hashes of
the package to the namespace of the main package itself. So
for the interpreter these look as though the subroutines
are part of the main package itself and so there is no need
to use the scope resolution operator while calling them.
This is usually done like:
use Exporter;
our @ISA=('Exporter');
our @EXPORT=('$x','@arr',subroutine)
(you are exporting a scalar, array and a sub-routine from
the package). So if some .plx is using the above package
they need not use the scope resolution to call these.
A direct access like "print $x" would work even without
using the scope resolution.

Ques:- Write a script for ‘count the no.of digits using regular expressions in perl..
Asked In :-
Comments
Admin May 17, 2020

Simple guys here we go :-).........
#!/usr/bin/perl -w
use strict;
my($test,$number) = ("","");
$test = "12344tyyyyy456";
$number = ($test =~ tr/[0-9]/[0-9]/);
print "Number of digits in variable is :- $number ";
exit;

Admin May 17, 2020

($test,$number) = ("","");
$test = "12344tyyyyy456";
@test=split('',$test);
foreach(@test)
{
if ($_ =~ /d/)
{$number++;
}
}
print $number;

Ques:- i have a folder called ‘error’ and in that, i have error log files which are generated by the build, now i want to findout the string ‘error’ from each log file and that error has to be copied into the another file called ‘analysis’. how do you do this in perl?
Asked In :-
Comments
Admin May 17, 2020

# Correction to my above post
$infile = 'errorlog.txt';
$outfile = 'analysys.txt';
open(INFILE,"$infile") || die "Unable to Open $infile-$!";
open(OUTFILE,">$outfile") || die "Unable to Open $outfile-
$!";
while ( <INFILE> ) {
print OUTFILE $_ if (/error/);
}
close INFILE;
close OUTFILE;

Admin May 17, 2020

## Go to that Directory
my $file_output = "output";
open(OUTFILEHANDLE,">$file_output") || die "Unable to open
the file : $file_output";
foreach my $input_file (`ls -1`) {
open(INFILEHANDLE,"$input_file") || die "Unable to
open the file : $input_file";
while (<INFILEHANDLE>) {
print OUTFILEHANDLE $_ if (/print header/);
}
}



The CGI Perl category on takluu.com is tailored for those who want to master web scripting and server-side programming using Perl in the context of CGI (Common Gateway Interface). Whether you’re applying for roles in legacy systems, automation testing, or back-end services, this section provides deep insights into Perl’s role in building dynamic web content.

Here, you’ll find the most commonly asked interview questions that test your understanding of CGI architecture, Perl syntax, form handling, server environment variables, file operations, and security practices in web applications.

Frequently covered questions include:

  • “What is CGI and how does it work with Perl?”

  • “How do you read form input using CGI Perl?”

  • “What are the advantages of using CGI with Perl?”

  • “How can you handle file uploads securely in CGI scripts?”

  • “Explain the difference between GET and POST methods in CGI.”

We break down complex scripting techniques into simple explanations and provide sample code snippets that mirror real-world scenarios. Whether you’re a beginner trying to understand the fundamentals or an experienced developer brushing up for an interview, this category offers immense value.

Our content is updated regularly based on recent interview patterns from tech companies that still rely on CGI-based systems or maintain older infrastructures.

Let Takluu be your preparation partner for CGI Perl roles and give you the confidence to crack even the toughest questions.

AmbitionBox Logo

What makes Takluu valuable for interview preparation?

1 Lakh+
Companies
6 Lakh+
Interview Questions
50K+
Job Profiles
20K+
Users