Find Interview Questions for Top Companies
Ques:- how to find a substring in a string without using substr built in functions, and print the substring found
Asked In :-
Comments
Admin May 17, 2020

$r="YASHWANTH";
@n=split (//,$r);
print "@nn";
@t=splice(@n,0,3);
print "@tn";
$r=join("",@t);
print "$rn";
~
~

Admin May 17, 2020

#!/usr/bin/perl
print"enter string
";
$str=<stdin>;
print"enter substring
";
$substr=<stdin>;
if($str=~$substr){
    print"valid
";
}
else
{
print"invalid
";
}

Ques:- what is the meaning of rigging?
Asked In :-
Comments
Admin May 17, 2020

Rigging is use for if we want to give animation for any
object or character then we apply to character or object
internel bone setting(like our bones).that is called
rigging. when apply rigging, then we can give proper
animation.

Ques:- Why do you use only Perl when there a lot of more languages available in market like C, Java?
Asked In :-
Comments
Admin May 17, 2020

compare to other c and java perl is having strong regluar
expression concept so data extraction will be easier and
complition will be faster too

Ques:- $@ set if error occur”
Asked In :-
Ques:- What is the difference between having a parenthesis after module name and without parenthsis after module name?? i.e Package::Module(); and Package::Module;
Asked In :-
Comments
Admin May 17, 2020

Package::Module(); This will throw as error,
I think,the question should be as: What is the difference
between,
Package::MyModule qw(); # FIRST
and
Package::MyModule; # SECOND
# FIRST :- This will not import any subroutine from MyModule.
# SECOND :- This will import all the subroutine from the
MyModule.

Ques:- write a perl script to find whether a given line of text is starting and ending with same word or not ???
Asked In :-
Comments
Admin May 17, 2020

Lets assume that the text to match is present in a file
say "data.txt".
Following program will print the line containing same
starting and ending word.
open(FILE,"data.txt") or die "cannot open file : $!";
while(<FILE>) {
if($_ =~ /^(w+)s+.*?1$/) {
print "the line is $_ n";
}
}

Admin May 17, 2020

Above solution ($_ =~ /^(w+)s+.*?1$/) does not work for
string like "vipul on allinterview.com onvipul";
I would suggest :
if( $_ =~ /^([^s]+)(s.*?)*s1$/ ) {
print "the line is $_ n";
}

Ques:- how to create a flat file database as shown below s.no name age city phone 0 hema 22 Calcutta 4312542 1 hema 21 Bangalore 2344345 2 ganesh 25 delhi 2445454 3 kartik 45 pune 4312121 4 santosh 25 Hyderabad 2254231 5 kumar 25 mysore 2344567 6 gita 34 mangalore 6532123 7 gita 32 pune 2213456 Q1.print the details of the person who r from bangalore q2.Replace the city name managlore to pune q3.prints no of person having name gita and hema q4.print how many are of age 25.
Asked In :-
Ques:- write a Perl script to find a particular word in a paragraph???
Asked In :-
Comments
Admin May 17, 2020

[code]
my $pat;
$pat='Using push we can add multiple items into an array in
a single instance.
If we are trying to add a module or library files in
our program using require or use statement then it will
search that module or library files in the Perl's default
search path.
The statement use lib is used to add the directories
to default search path.
So if the module or library file is not located in
the Perl's default search path then it will find the
library files in the path we have given with the use lib
$path.';
if($pat=~/push/)
{
print "Pattern push get matchedn";
}
[/code]

Ques:- How to make the following assignment, as arrayreference assignment ? my $arr_ref='[1,2,3,4,4,’elem’]’;
Asked In :-
Comments
Admin May 17, 2020

Refer this program.
[code]
my $ref=[1,2,3,4];
print ref $ref;
[/code]

Admin May 17, 2020

my $ref=[1,2,3,4];
print ref $ref;
ref will return the type of reference.
In this case ref will return as 'ARRAY'.

Ques:- what are steps to do to lock the sony ericsson mobile with password?
Asked In :-
Ques:- how to extract pin_code,phone_number,year from text file using regular expressions in perl
Asked In :- Primus Techsystems,
Ques:- What is caller function in perl?
Asked In :-
Comments
Admin May 17, 2020

print caller;

Ques:- How to disable the mod_perl from apache_server as i have used perlfect search on the site and its pagination is not working and the remedy is to disable the mod_perl.
Asked In :- Twilight IT Solutions,
Ques:- Why we use “use lib $path”?
Asked In :-
Comments
Admin May 17, 2020

If we are trying to add a module or library files in our
program using require or use statement then it will search
that module or library files in the Perl's default search path.
The statement use lib is used to add the directories to
default search path.
So if the module or library file is not located in the
Perl's default search path then it will find the library
files in the path we have given with the use lib $path.

Ques:- Difference between Perl and Mod_perl?
Asked In :-
Comments
Admin May 17, 2020

Thanks Faisal

Admin May 17, 2020

Perl is a language and MOD_PERL is a module of Apache used
to enhance the performance of the application.

Ques:- write a script to generate n prime no.s?
Asked In :-
Comments
Admin May 17, 2020

#!c:perlbinperl
$Count = 0;
$pt = 2;
while ( $Count < @ARGV[0] )
{
if (isPrimary($pt))
{
print "$ptn";
$Count++;
}
$pt++;
}
sub isPrimary
{
$flag = 1;
for ($i=2; $i<=$_[0]/2; $i++)
{
if ($_[0] % $i == 0)
{
$flag = 0;
}
}
return $flag;
}

Admin May 17, 2020

import java.io.*;
import java.util.*;
class Prime
{
static BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
int cnt = 0,j;
Prime()
{
try
{
System.out.print("Enter A Number :");
int n = Integer.parseInt(br.readLine());
for(int i =1 ;i <= n ;i++)
{
for( j = 1 ; j <= i ;j++)
{
if(j==1) //as 1 is Common Factor For
All
{
cnt ++;
}
if(i % j == 0 && j !=i) //Condition j!=i because at
1st loop
//i=1 j=1 so i%j==0 and 1 is not prime no
{
cnt ++;
}
if(cnt == 3)
{
break;
}
if(cnt==2 && i == j )
{
System.out.println(i);
}
}
cnt=0;
}
}
catch(Exception e)
{
System.out.println(e);
}
}
public static void main(String args[])
{
new Prime();
}
}

Ques:- write a script to check whether user enter a value is a leap year or not?
Asked In :-
Comments
Admin May 17, 2020

#call this function by passing the year....
sub isLeapyear
{
$year=shift;
if($year%4==0){
if($year%100==0){
if($year%400==0)
return 1;
return 0;
}
return 1;
}
}

Admin May 17, 2020

#The logic is that the year is either divisible by both
100 and 4 , OR its only divisible by 4 not by hundred
if($Year%400 == 0 || ($Year%100 != 0 && $Year%4 == 0))
{
print "Leap year n";
}
else
{
print "Not Leap n";
}

Ques:- write a script to display mirror image of a entered value and also check whether Palindrome
Asked In :-
Comments
Admin May 17, 2020

print("Enter the no. to check for Palindrome : ");
my $no = <STDIN>;
chop($no);
my $rev =reverse($no);
print "Palindrom n" if ($rev eq $no);
#Perl cannot identify the datatype until we force operation
on it;

Admin May 17, 2020

print("Enter the no. to check for Palindrome : ");
$no = <STDIN>;
chop($no);
$i = 0;
# Store into a array
while($no != 0)
{
@array[$i] = $no % 10;
$no = int($no / 10);
$i++;
}
$i--;
$j=0;
$flag = "true";
# Check for Palindrome
while( ($flag eq "true" )&& ( $j < @array/2) ){
if (@array[$j] != @array[$i])
{
$flag = "false"
}
$i--;
$j++;
}
# Print the result
if( $flag eq "true")
{
print("It is a Palindromen");
}
else
{
print("It is NOT a Palindromen");
}

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

Both are absolutely same in giving the output.
but in first method "$array [++$#array] = 'ree';"
we are preincrementing the array index manually and assigning the latest index to 'ree'; (SLower since we doing it as manual)
Where as in the second method, push is an array function where we need not care about index. it automatically increases the index value for the array. (Faster)
Both give same output as
data1 data2 ree
data1 data2 ree ree
data1 data2 ree ree ree
data1 data2 ree ree ree ree
data1 data2 ree ree ree ree ree
data1 data2 ree ree ree ree ree ree
data1 data2 ree ree ree ree ree ree ree
VALUES FOR K
data1 data2 ree
data1 data2 ree ree
data1 data2 ree ree ree
data1 data2 ree ree ree ree
data1 data2 ree ree ree ree ree
data1 data2 ree ree ree ree ree ree
data1 data2 ree ree ree ree ree ree ree

Admin May 17, 2020

Both are same

Ques:- Consider the following example #! /bin/perl use strict; sub sample { my @arr=(1,2,3,4); return @arr; } my ($a,$b,$c,$d) = &sample; print “$an$bn$cn$dn”; In the above code, How can I get the $c without using the arguments such as $a,$b. I don’t want to use any array to get the return values.
Asked In :-
Comments
Admin May 17, 2020

# Here is another solution
use strict;
sub sample {
my @arr = (1,2,3,4);
return @arr; # return the array reference
}
my $aref = &sample;
print $aref->[2];

Admin May 17, 2020

Try with the following program.
[code]
sub sample
{
my @arr=(1,2,3,4);
return @arr;
}
my $c=(&sample)[2];
print $c;
Variable 'c' will contain the value '3'.



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