- World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.

Get it now !!
Send your Resume to 6000 Companies
Perl Interview Questions & Answers - Learning Mode

Perl Interview Questions & Answers - Learning Mode

Perl is a script programming language that is similar in syntax to the C language and that includes a number of popular UNIX facilities such as sed, awk, and tr. Perl is an interpreted language that can optionally be compiled just before execution into either C code or cross-platform bytecode. Perl is a general-purpose programming language originally developed for text manipulation and now used for a wide range of tasks including system administration, web development, network programming, GUI development, and more.

Try Perl Interview Questions & Answers - Exam Mode

1 2 3 4 Next

Sort By : Latest First | Oldest First | By Rating

Perl Interview Questions & Answers - Learning Mode
Try Perl Interview Questions & Answers - Exam Mode
Question: What is a subroutine?

Answer: A subroutine is like a function ... called upon to excecute a task. Source:
Question: Given a file, count the word occurrence (case insensitive)

Answer: open(FILE,"filename");
$wor="word to be found";
foreach $line (@array)
@arr=split (/s+/,$line);
foreach $word (@arr)
if ($word =~ /s*$wors*/i)
print "The word occurs $count times";
Question: How many ways can we express string in Perl?

Answer: For example 'this is a string' can be expressed in:
"this is a string"
qq/this is a string like double-quoted string/
qq^this is a string like double-quoted string^
q/this is a string/
q&this is a string&
q(this is a string) Source:
Question: What is meant by 'chomp'? where do we require this ?

Answer: chomp is used to eliminate the new line character. It can used in many different scenarios.<br><br>For ex: firstArgument.<br><br>$firstArg = $ARGV[0];<br><br>chomp $firstArg; --> to get rid of the carrige return.<br> Source:
Question: How to turn on Perl warnings? Why is that important?

Answer: Perl is very forgiving of strange and sometimes wrong code, which can mean hours spent searching for bugs and weird results. Turning on warnings helps uncover common mistakes and strange places and save a lot of debugging time in the long run. There are various ways of turning on Perl warnings:

* For Perl one-liner, use -w option on the command line.
* On Unix or Windows, use the -w option in the shebang line (The first # line in the script). Note: Windows Perl interpreter may not requ Source:
Question: Explain the difference between "my" and "local" variable scope declarations. ?

Answer: The variables declared with my() are visible only within the scope of the block which names them. They are not visible outside of this block, not even in routines or blocks that it calls. local() variables, on the other hand, are visible to routines that are called from the block where they are declared. Neither is visible after the end (the final closing curly brace) of the block at all. Source:
Question: When would `local $_' in a function ruin your day?

Answer: When your caller was in the middle for a while(m//g) loop
The /g state on a global variable is not protected by running local on it. That'll teach you to stop using locals. Too bad $_ can't be the target of a my() -- yet. Source:
Question: What does new $cur->{LINK} do?

Answer: $cur->new()->{LINK}
The indirect object syntax only has a single token lookahead. That means if new() is a method, it only grabs the very next token, not the entire following expression.
This is why `new $obj[23] arg' does't work, as well as why `print $fh[23] "stuff "' does't work. Mixing notations between the OO and IO notations is perilous. If you always use arrow syntax for method calls, and nothing else, you'll not be surprised. Source:
Question: What is meant by a 'pack' in perl?

Answer: Pack Converts a list into a binary representation<br><br>Takes an array or list of values and packs it into a binary structure, returning the string containing the structure<br><br>Hope that kills the problem !! <br><br> <br> Source:
Question: When do you not use Perl for a project?

Answer: When:<br><br>- There's a lot of text processing<br><br>- Web-based applications<br><br>- Fast/expidient development <br><br>- Shell scripts grow into libraries<br><br>- Heavy Data manipulation (auditing, accounting, checking etc... backend processing)<br><br>- Data extraction <br><br>- transform <br><br>- loading (database etc.)<br><br>- System admin etc... Source:
Question: Why does Perl not have overloaded functions?

Answer: False so long as f() returns false, after which it returns true until g() returns true, and then starts the cycle again.
This is scalar not list context, so we have the bistable flip-flop range operator famous in parsing of mail messages, as in `$in_body = /^$/ .. eof()'. Except for the first time f() returns true, g() is entirely ignored, and f() will be ignored while g() later when g() is evaluated. Double dot is the inclusive range operator, f() and g() will both be evaluated on the sa Source:
Question: How do I read command-line arguments with Perl?

Answer: With Perl, command-line arguments are stored in the array named @ARGV.
$ARGV[0] contains the first argument, $ARGV[1] contains the second argument, etc.
$#ARGV is the subscript of the last element of the @ARGV array, so the number of arguments on the command line is $#ARGV + 1.
Here's a simple program:
$numArgs = $#ARGV + 1;
print "thanks, you gave me $numArgs command-line arguments. ";
foreach $argnum (0 .. $#ARGV) {
print "$ARGV[$argnum] ";
} Source:
Question: Determine the difference between my and local?

Answer: The fundamental difference between my and local is that my creates a new variable, whereas local saves a copy of an existing variable.
Question: Describe about the security vulnerability of PHP?

Answer: According to the information obtained from the National vulnerability database, PHP has more than quarter of the software vulnerabilities discovered in 2008. Out of 33.33% software and scripts vulnerability PHP amounts to almost quarter of them. Register_globals a feature present in PHP is responsible for most of these vulnerabilities and now it is deprecated by PHP. Most of these security vulnerabilities occur due to poor programming techniques. Source:
Question: How do you connect to database in perl

Answer: There is DBI module.use DBI;my $dbh = DBI->connect('dbi:Oracle:orcl', 'username', 'password',)where username and password is yours. THis is exmaple for oracle database. Source:
Question: How many ways can we express string in Perl?

Answer: Many. For example 'this is a string' can be expressed in:
"this is a string"
qq/this is a string like double-quoted string/
qq^this is a string like double-quoted string^
q/this is a string/
q&this is a string&
q(this is a string) Source:
Question: What is a short circuit operator?

Answer: The C-Style operator, ll, performs a logical (or) operation and you can use it to tie logical clauses together, returning an overall value of true if either clause is true. This operator is called a short-circuit operator because if the left operand is true the right operand is not checked or evaluated. Source:
Question: How do I set environment variables in Perl programs?

Answer: As you may remember, "%ENV" is a special hash in Perl that contains the value of all your environment variables.
Because %ENV is a hash, you can set environment variables just as you'd set the value of any Perl hash variable. Here's how you can set your PATH variable to make sure the following four directories are in your path::

$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/home/yourname/bin'; Source:
Question: What is Perl one-liner?

Answer: There are two ways a Perl script can be run:
--from a command line, called one-liner, that means you type and execute immediately on the command line. You'll need the -e option to start like "C: %gt perl -e "print "Hello";". One-liner doesn't mean one Perl statement. One-liner may contain many statements in one line.
--from a script file, called Perl program. Source:
Question: Explain about lists?

Answer: A list is a construct that associates data elements together and you can specify a list by enclosing those elements in parenthesis and separating them with commas. They could themselves be arrays, hashes or even other lists. Lists do not have a specific list data type. Source:

1 2 3 4 Next

India News Network
Latest 20 Questions
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
"Holiday Packages" announced as an advertisement are an example of _________: (a) Offer (b) Counter Offer (c) Invitation to Offer (d) None of the above
A match fixing contract between a player and a broker is a: (a) Valid Contract (b) Unenforceable Contract (c) Void Contract (d) Illegal Contract
When a bookseller sells a book on cash payment then it is called as ___________: (a) Unilateral Contract (b) Bilateral Contract (c) Executed Contract (d) Executory Contract
____________ agreements are created by situation: (a) Written (b) Oral (c) Void (d) Implied
Cache = 0.023438 Seconds