Perl Scripting Interview Questions and Answers

Perl Scripting Interview Questions and Answers

Last updated on 21st Oct 2020, Blog, Interview Question

About author

Gupta ( (Sr Project Manager ) )

High level Domain Expert in TOP MNCs with 8+ Years of Experience. Also, Handled Around 20+ Projects and Shared his Knowledge by Writing these Blogs for us.

(5.0) | 11547 Ratings 2220

These Perl Scripting Interview Questions have been designed specially to get you acquainted with the nature of questions you may encounter during your interview for the subject of Perl Scripting . As per my experience good interviewers hardly plan to ask any particular question during your interview, normally questions start with some basic concept of the subject and later they continue based on further discussion and what you answer.we are going to cover top 100 Perl Scripting  Interview questions along with their detailed answers. We will be covering Perl Scripting  scenario based interview questions, Perl Scripting  interview questions for freshers as well as Perl Scripting  interview questions and answers for experienced. 

1. Define Perl Scripting?

Ans:

In the IT market, Perl scripting is considered as a robust scripting language which is used in various fields. Perl is good at obtaining Regular expressions and in all the fields of application it is unique. Perl is a scripting language which is based on interpreter but not on the languages based on compiler. In all the applications, optimization is used.

2. Why To Use Perl Scripting?

Ans:

Perl scripting is mainly used in functional concepts as well as regular expressions, you can also design own policies to obtain generalized pattern using regular expression. Perl is compatible or supports more than 76 operating systems and 3000 modules and it is known as Comprehensive Perl Archive Network modules.

3. What Is Perl?

Ans:

Perl is a programming language which is based on shell, C, Lisp, etc. In general, Perl is mainly used for network operations, OS program and for developing some websites.

4. Why To Use Perl?

Ans:

  • It is a powerful interpreter for free.
  • Perl is flexible and portable. It is very easy to learn Perl language.

5. Why Do You Create An Application For Real Time System In Which Processing Speed Is Vital?

Ans:

Perl is used in the following cases:

  1. 1. To process large text
  2. 2. When data manipulation is done by application
  3. 3. If you require fast developments expand to become libraries
  4. 4. To load database operations

6. Which Is Your Favorite Module And Why It Is?

Ans:

CGI.pm is my favorite module and it handles several tasks such as printing the headers, parsing the form input and it handles sessions and cookies effectively.

7. How Perl Warnings Are Turn On And Why Is It Important?

Ans:

In general, Perl excuse strange and also wrong code sometimes. Thus, the time spent for searching weird results and bugs in very high. You can identify common mistakes and strange places in the code easily when warnings are turned on. In the long run, the time required for debugging is saved a lot. There are numerous ways to turn on the warnings of Perl:

  • -w option is used on the command line for Perl one-liner
  • -w option on shebang line is used on windows or UNIX. Windows Perl interpreter do not require it.
  • For other systems, compiler documentation is checked or compiler warnings are selected.

8. Differentiate Use And Require?

Ans:

Use

  1. 1. This method is used for modules.
  2. 2. The objects which are included are varied at compilation time.
  3. 3. You need not give a file extension.

Require

  1. 1. This method is used for both modules and libraries.
  2. 2. The objects are included are verified at run time.
  3. 3. You need not give file extension.
Subscribe For Free Demo

Error: Contact form not found.

9. Distinguish My And Local?

Ans:

The variables which are declared using “my” lives only in that particular block ion which they are declared and inherited functions do not have a visibility that are called in that block. The variables which are defined as “local” are visible in that block and they have a visibility in functions which are called in that particular block.

10. Why Perl Patterns Are Not Regular Expressions?

Ans:

Perl patterns have back references
By the definition, a regular expression should determine next state infinite automation without extra money to keep in previous state. State machine is required by the pattern / ([ab] +) c1/ to remember old states. Such patterns are disqualified as being regular expressions in the term’s classic sense.

11. What Happens If A Reference Is Returned To Private Variable?

Ans:

Your variables are kept on track by the Perl, whether dynamic or else, and does not free things before you use them.

12. Define Scalar Data And Variables?

Ans:

The concept of data types is flexible, which is present in Perl. Scalar is a single thing such as a string or a number. The java concepts such as int, float, string, and double are similar to scalar concept of Perl. Strings and numbers are exchangeable. Scalar variable is nothing but a Perl variable which is used to store scalar data. A dollar sign $ is used by it which is followed by underscores or alphanumeric characters. It is a case sensitive.

13. Why -w Argument Is Used With Perl Programs?

Ans:

-w option of the interpreter is used by most of the Perl developers especially in the development stage of an application. It is warning option to turn on multiple warning messages that are useful in understanding and debugging the application.

14. Which Has Highest Precedence In Between List And Terms? Explain?

Ans:

In Perl, the highest precedence is for Perl. Quotes, variables, expressions in parenthesis are included in the Terms. The same level of precedence as Terms is for List operators. Especially, these operators have strong left word precedence.

15. Define A Short Circuit Operator?

Ans:

The C-style operator ll carries out logical operation which is used to tie logical clauses, overall value of true is returned if either clause is true. This operator is known as short-circuit operator because you need not check or evaluate right operand if the left operand is true.v

16. In Perl, Name Different Forms Of Goto And Explain?

Ans:

In Perl, there are three different forms for goto, they are:

  • goto name
  • goto label
  • goto expr

goto name is used along with subroutines, it is used only when it is required as it creates destruction in programs. It is the second form of label where Execution is transferred to a statement labeled LABEL using goto LABEL. The last label form is goto EXPR which expects EXPR to evaluate label.

17. Can You Add Two Arrays Together?

Ans:

Yes, it is possible to add two arrays together with a push function. A value or values to end of the array is added using push function. The values of list are pushed on to the end of an array using push function. Length of list is used to increase length of an array.

18. How Shift Command Is Used?

Ans:

The first value of an array shifted using shift array function and it is returned, which results in array shortening by one element and moves everything from a place to left. If an array is not specified to shift, shift uses @ ARGV, the command line arguments of an array is passed to script or to an array named @.

19. Explain Different Types Of Eval Statements?

Ans:

In general, there are two types of eval statements they are:

  1. 1. Eval BLOCK and
  2. 2. Eval EXPR

An expression is executed by eval EXPR and BLOCK is executed by eval BLOCK. Entire block is executed by eval block, BLOCK. When you want your code passed in expression then first one is used and to parse code in the block, second one is used.

20. Describe Returning Values From Subroutines?

Ans:

The value of last expression which is evaluated is the return value of subroutine or explicitly, a returned statement can be used to exit subroutine which specifies return value. This return value is evaluated in perfect content based on content of subroutine call.

21. What Are The Two Different Types Of Data Perl Handles?

Ans:

Perl handles two types of data they are,
whereas

  • Scalar Variables – Scalar variables hold a single data item.
  • Lists – Lists hold multiple data items.

22. What Are Scalar Variables?

Ans:

Scalar variables are what many programming languages refer to as simple variables. They hold a single data item, a number, a string, or a perl reference. Scalars are called scalars to differentiate them from constructs that can hold more than one item, like arrays.

23. Explain About Lists?

Ans:

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.

24. Name All The Prefix Dereferencer In Perl?

Ans:

The symbol that starts all scalar variables is called a prefix dereferencer. The different types of dereferencer are,

  • $-Scalar variables
  • (ii) %-Hash variables
  • (iii) @-arrays
  • (iv) &-subroutines
  • (v) Type globs-*myvar stands for @myvar, %myvar.

25. Explain About An Ivalue?

Ans:

An ivalue is an item that can serve as the target of an assignment. The term I value originally meant a “left value”, which is to say a value that appears on the left. An ivalue usually represents a data space in memory and you can store data using the ivalues name. Any variable can serve as an ivalue.

26. How Does A “grep” Function Perform?

Ans:

Grep returns the number of lines the expression is true. Grep returns a sub list of a list for which a specific criterion is true. This function often involves pattern matching. It modifies the elements in the original list.

27. Explain About Typeglobs?

Ans:

Type globs are another integral type in perl. A typeglob`s prefix derefrencer is *, which is also the wild card character because you can use typeglobs to create an alias for all types associated with a particular name. All kinds of manipulations are possible with typeglobs.

28. Is There Any Way To Add Two Arrays Together?

Ans:

Of course you can add two arrays together by using push function. The push function adds a value or values to the end of an array. The push function pushes the values of list onto the end of the array. Length of an array can be increased by the length of list.

Course Curriculum

Enroll in PERL Scripting Training & Build Your Skills to Next Level

  • Instructor-led Sessions
  • Real-life Case Studies
  • Assignments
Explore Curriculum

29. How To Use The Command Shift?

Ans:

Shift array function shifts off the first value of the array and returns it, thereby shortening the array by one element and moving everything from one place to the left. If you don’t specify an array to shift, shift uses @ ARGV, the array of command line arguments passed to the script or the array named @-.

30. What Exactly Is Grooving And Shortening Of The Array?

Ans:

You can change the number of elements in an array simply by changing the value of the last index of/in the array $#array. In fact, if you simply refer to a nonexistent element in an array perl extends the array as needed, creating new elements. It also includes new elements in its array.

31. What Are The Three Ways To Empty An Array?

Ans:

The three different ways to empty an array are as follows

  1. 1. You can empty an array by setting its length to a negative number.
  2. 2. Another way of empting an array is to assign the null list ().
  3. 3. Try to clear an array by setting it to undef, but be aware when you set to undef.

32. How Do You Work With Array Slices?

Ans:

An array slice is a section of an array that acts like a list, and you indicate what elements to put into the slice by using multiple array indexes in square brackets. By specifying the range operator you can also specify a slice.

33. What Is Meant By Splicing Arrays Explain In Context Of List And Scalar.

Ans:

Splicing an array means adding elements from a list to that array, possibly replacing elements now in the array. In list context, the splice function returns the elements removed from the array. In scalar context, the splice function returns the last element removed.

34. What Are The Different Types Of Perl Operators?

Ans:

There are four different types of perl operators they are,

  1. 1. Unary operator like the not operator
  2. 2. Binary operator like the addition operator
  3. 3. Tertiary operator like the conditional operator
  4. 4. List operator like the print operator

35. Which Has The Highest Precedence, List Or Terms? Explain?

Ans:

Terms have the highest precedence in perl. Terms include variables, quotes, expressions in parenthesis etc. List operators have the same level of precedence as terms. Specifically, these operators have very strong left word precedence.

36. What Is Perl Scripting?

Ans:

Perl Scripting is one of the robust scripting languages in the IT market which is being used in “n” of fields. Perl is rich in finding Regular expressions and stands unique in all fields of application.
PERL is a scripting language. Since all scripting languages are interpreter based languages but not compiler based languages, we use for optimization of code in all application.

37. Why Do We Use Perl Scripting?

Ans:

We use PERL scripting because it is rich in all regular expressions and functional concepts, we can create our own rules to find out particular generalized pattern by using regular expression. PERL supports or compatible in almost 76+ Operating systems and supports more than 3000 modules, called as CPAN (Comprehensive Perl Archive Network) modules.

38. What Is A Subroutine?

Ans:

Subroutine is perl is a block of code specially combined/grouped to perform a particular task. Which can be called at any point of time in a perl program.

Advantage using Subroutine :

  • helps in modular programming making it easier to understand and maintain.
  • eliminates duplication by reusing the same code/calling the subroutine.

39. Name An Instance You Used In Cpan Module?

Ans:

CGI, DBI etc are very common packages used from CPAN. there are thousands of other useful modules.

40. I Have A Variable Named $objref Which Is Defined In Main Package. I Want To Make It As A Object Of Class Xyz. How Could I Do It?

Ans:

  • use XYZ;
  • my $objref= XYZ->new();

41. What Is Meant ‘die’ In A Perl Program?

Ans:

If the condition defined before the DIE statement is NOT met, the script will stop execution at that point, printing out the default error, if a custom error message is not defined.

42. What Is Hash In Perl?

Ans:

Hash in basically used to comment the script line.
A hash is and unordered set of key/value pairs that you access using strings (keys) as subscripts, to look up the scalar value corresponding to a given key.

43. What Does This Mean :’$_’ ?

Ans:

Its an Default variable in Perl, where the input from the user will be taken into this variable if the variable is not defined by the user

44. What Is A Datahash(). What Does It Mean? And For What Purpose It Is Used??

Ans:

In Win32::ODBC, DataHash() function is used to get the data fetched through the sql statement in a hash format.

45. Explain About Returning Values From Subroutines (functions)?

Ans:

The return value of the subroutine is the value of the last expression evaluated or you can explicitly use a return statement to exit the subroutine specifying the return value. That return value is evaluated in the appropriate content depending on the content of the subroutine call.

46. What Is Meant By A ‘pack’ In Perl?

Ans:

  • Pack Converts a list into a binary representation
  • Takes an array or list of values and packs it into a binary structure, returning the string containing the structure
  • Hope that kills the problem

47. How Do You Connect To Database In Perl

Ans:

There is DBI module. use DBI;my $dbh = DBI->connect(‘dbi:Oracle:orcl’, ‘username’, ‘password’,)where username and password is yours. This is example for oracle database.

For Sybase:

  • use DBI;
  • my $dbh = DBI->connect(‘dbi:Sybase:server=$SERVER’, ‘username’, ‘password’)

48. What Is A Short Circuit Operator?

Ans:

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.

49. How To Connect With Sqlserver From Perl And How To Display Database Table Info?

Ans:

There is a module in perl named DBI – Database independent interface which will be used to connect to any database by using same code. Along with DBI we should use database specific module here it is SQL server. for MSaccess it is DBD::ODBC, for MySQL it is DBD::mysql driver, for integrating oracle with perl use DBD::oracle driver is used. IIy for SQL server there are available many custom defined ppm( perl package manager) like Win32::ODBC, mssql::oleDB etc.so, together with DBI, mssql::oleDB we can access SQL server database from perl. The commands to access database is same for any database.

50. What Value Is Returned By A Lone Return; Statement?

Ans:

The undefined value in scalar context, and the empty list value () in list context. This way functions that wish to return failure can just use a simple return without worrying about the context in which they were called.

51. How To Turn On Perl Warnings? Why Is That Important?

Ans:

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. 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 require it.
  • For other systems, choose compiler warnings, or check compiler documentation.

52. Write A Script To Reverse A String Without Using Perl’s Built In Functions?

Ans:

  • my $txt = ‘Hello World’;
  • my $len= length($txt);
  • my $rev;
  • while($len > 0){
  • $len–;
  • $rev .= substr($txt,$len,1);
  • }
  • print $txt, ‘ – Reversed = ‘ , $rev;

53. What Is Perl One-liner?

Ans:

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.

54. What Are The Different Types Of Eval Statements?

Ans:

There are two different types of eval statements they are,

  1. 1. eval EXPR
  2. 2. eval BLOCK.

Eval EXPR executes an expression and eval BLOCK executes BLOCK. Eval Block executes an entire block, BLOCK. First one is used when you want your code passed in the expression and the second one is used to parse the code in the block.

55. What Is Your Experience Of Interfacing Perl To Database?

Ans:

The correct answer is DBI

56. What Is Cpan ? What Are The Modules Coming Under This?

Ans:

CPAN is Comprehensive Perl Archive Network. It’s a repository contains thousands of Perl modules, source and documentation, and all under GNU/GPL or similar license. Some Linux distributions provide a tool named “cpan” with which you can install packages directly from CPAN

Course Curriculum

Get PERL Scripting Certification Courses with Industry Standard Syllabus

Weekday / Weekend BatchesSee Batch Details

57. Given A File, Count The Word Occurrence (case Insensitive)?

Ans:

  • open(FILE,”filename”);
  • @array=; $wor=”word to be found”;
  • $count=0; foreach $line (@array)
  • {
  • @arr=split (/s+/,$line);
  • foreach $word (@arr)
  • {
  • if ($word =~ /s*$wors*/i) $count=$count+1;
  • }
  • }
  • print “The word occurs $count times”;

58. How Do I Set Environment Variables In Perl Programs?

Ans:

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’;

59. Why We Use Perl?

Ans:

  1. 1.Perl is a powerful free interpreter.
  2. 2.Perl is portable, flexible and easy to learn.
  3. 3. For shell scripting
  4. 4. For CGI
  5. 5. Tons of scripts are available.
  6. 6. Easy development
  7. 7. Enormous big support script archive like CPAN
  8. 8. No one starts to write a Perl scripts from scratch, you choose one from an archive and modify that.
  9. 9. It is a “mature” scripting language.
  10. 10. You may find Perl interpreter on every mission critical environment
  11. 11. Easy to learn

60. Why Does Perl Not Have Overloaded Functions?

Ans:

Because you can inspect the argument count, return context, and object types all by yourself.
In Perl, the number of arguments is trivially available to a function via the scalar sense of @_, the return context via want array(), and the types of the arguments via ref() if they’re references and simple pattern matching like /^d+$/ otherwise. In languages like C++ where you can’t do this, you simply must resort to overloading of functions.

61. Which Of These Is A Difference Between C++ And Perl?

Ans:

Perl can have objects whose data cannot be accessed outside its class, but C++ cannot.
Perl can use closures with unreachable private data as objects, and C++ doesn’t support closures. Furthermore, C++ does support pointer arithmetic via `int *ip = (int*)&object’, allowing you do look all over the object. Perl doesn’t have pointer arithmetic. It also doesn’t allow `#define private public’ to change access rights to foreign objects. On the other hand, once you start poking around in /dev/mem, no one is safe.

62. How To Concatenate Strings With Perl?

Ans:

Method #1 – using Perl’s dot operator:

  • $name = ‘checkbook’;
  • $filename = “/tmp/” . $name . “.tmp”;

Method #2 – using Perl’s join function

  • $name = “checkbook”;
  • $filename = join “”, “/tmp/”, $name, “.tmp”;

Method #3 – usual way of concatenating strings

  • $filename = “/tmp/${name}.tmp”;

63. What Is The Difference Between Chop & Chomp Functions In Perl?

Ans:

chop is used to remove last character,chomp function removes only line endings.

64. What Is Hash?

Ans:

Hash is an associative array where data is stored in
“key”->”value” pairs.
Eg : fruits is a hash having their names and price

  • %fruits = (“Apple”, “60”, “Banana”, “20”, “Peers”, “40”);

65. How Would You Replace A Char In String And How Do You Store The Number Of Replacements?

Ans:

  • $str=’Hello’;
  • $cnt= ($str=~s/l/i/g);
  • print $cnt;

66. How Do You Open A File For Writing?

Ans:

  • open FILEHANDLE, “>$FILENAME”

67. What’s Your Favorite Module And Why?

Ans:

My Favourite module is CGI.pm Because it can handle almost all the tasks like

  • parsing the form input
  • printiing the headers
  • can handle cookies and sessions and much more

68. How To Implement Stack In Perl?

Ans:

Stack is LIFO (Last in First out), In perl that could be inplemented using the push() and shift() functions. push() adds the element at the last of array and shift() removes from the beginning of an array.

69. Why Do You Program In Perl?

Ans:

  • Perl is easy, fast and its fun to code in perl.
  • Perl is rich with various packages, N/w programming is very easy and there are lot more advantages to say.

70. How We Can Navigate The Xml Documents?

Ans:

You can use SAX if what you require is simple accesing of the xml structure. You can go for DOM if you need node handling capabilities like inserting a node, modifying a node, deleteing node and stuff like that.

71. Help In Perl?

Ans:

  • perldoc -f print

72. What Is The Use Of “stderr()”?

Ans:

STDERR : The special filehandle for standard error in any package.

73. Advantages Of C Over Perl?

Ans:

In reality PERL interpreter is written in C. So what all advantages C have are also possesed by PERL. Otherwise C is faster than PERL, because PERL is an interpreted language.

74. Perl Regular Expressions Are Greedy” What Does This Mean?

Ans:

Perl regular expressions normally match the longest string possible. that is what is called as “greedy match”

75. What Does The Word ‘&myvariable’ Mean?What Does The Symbol ‘&’ Means? What’s Purpose Of It?

Ans:

  • &myvariable is calling a sub-routine.
  • & is used to identify a sub-routine.

76. What Is Super?

Ans:

Super refers to current package ancestor.

77. What Is Rpc? Why Do I Need It?

Ans:

RPC : A call to a procedure in a different address space. In a traditional procedure call, the calling procedure and the called procedure are in the same address space on one machine. In a remote procedure call, the calling procedure invokes a procedure in a different address space and usually on a different machine.

78. What Does Init 5 And Init 0 Do?

Ans:

init 5 : will shutdown and Power-off the server.

init 0 : will bring the server to the ok> prompt (Fourth monitor)

79. What Does Ndd Do?

Ans:

ndd command will hardcore the speed of the network interface card.

80. What Is Obp And How Do You Access It?

Ans:

OBP is called as Open Boot PROM. This OBP can be accessiable thru ok> prompt

81. How Do You Boot From Cd-rom?

Ans:

Booting form CD-ROM can be done by the command

  • ok >boot cdrom

82. What Is /etc/system For?

Ans:

/etc/system is a kernal file of Solaris OS.

83. How Do You Boot From A Network With Jumpstart?

Ans:

  • boot net – install

84. What Is Jumpstart?

Ans:

The Jumpstart feature is an automatic installation process available in the Solaris operating environment. It allows system administrators to categorize machines on their network and automatically install systems based on the category to which a system belongs.

Unix Shell Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

85. What Is Lom

Ans:

Short for LAN on motherboard. The term refers to a chip or chipset capable of network connections that has been embedded directly on the motherboard of a desktop, workstation or server. Instead of requiring a separate network interface card to access a local-area network, such as Ethernet, the circuits are attached to the motherboard. An advantage of a LOM system is an extra available PCI slot that is not being used by the network adapter.

86. How To Create A Package?

Ans:

  • pkgmk -o -r / -d /tmp -f Prototype

87. How Do You View Shared Memory Statistics?

Ans:

  1. 1. swap -l -> displays swap usage
  2. 2. prstat -> examines all active processes on the system and reports statistics based on the selected output mode and sort order
  3. 3. vmstat -> reports information about processes, memory, paging, block IO, traps and cpu activity
  4. 4. pmap -> lists the virtual memory mappings underlying the given process

88. What Is Vts?

Ans:

Sun Validation Test Suite -> Tests and validates Sun hardware by verifying the configuration and functionality of hardware controllers, devices

89. What Is Grep Used For In Perl?

Ans:

Grep is used with regular expression to check if a parituclar value exist in an array. it returns 0 if the value does not exists, 1 otherwise.

90. How To Code In Perl To Implement The Tail Function In Unix?

Ans:

You have to maintain a structure to store the line number and the size of the file at that time eg. 1-10bytes, 2-18bytes.. you have a counter to increase the number of lines to find out the number of lines in the file. once you are through the file, you will know the size of the file at any nth line, use ‘sysseek’ to move the file pointer back to that position (last 10) and then start reading till the end.

91. What Are The Arguements We Normally Use For Perl Interpreter

Ans:

  • -e for Execute
  • -c to compile
  • -d to call the debugger on the file specified
  • -T for traint mode for security/input checking
  • -W for show all warning mode (or -w to show less warning)

92. What Is It Meants By ‘$_’?

Ans:

It is a default variable which holds automatically, a list of arguements passed to the subroutine within parenthesis.

93. What Is The Tk Module?

Ans:

It provides a GUI interface.

94. How To Concatinate Strings In Perl?

Ans:

Through . operator

95. What Value Is Returned By A Lone ‘return;’ Statement?

Ans:

The undefined value in scalar context, and the empty list value () in list context. This way functions that wish to return failure can just use a simple return without worrying about the context in which they were called.

96. How Do Find The Length Of An Array?

Ans:

  • $@array

97. What Does Read() Return At End Of File?

Ans:

A defined (but false) 0 value is the proper indication of the end of file for read() and sysread().

98. How Do You Print Out The Next Line From A Filehandle With All Its Bytes Reversed?

Ans:

Print scalar reverse scalar Surprisingly enough, you have to put both the reverse and the into scalar context separately for this to work.

99. What Does Perl Do If You Try To Exploit The Execve(2) Race Involving Setuid Scripts?

Ans:

Sends mail to root and exits. It has been said that all programs advance to the point of being able to automatically read mail. While not quite at that point (well, without having a module loaded), Perl does at least automatically send it.

100. What Are Scalar Data And Scalar Variables?

Ans:

Perl has a flexible concept of data types. Scalar means a single thing, like a number or string. So the Java concept of int, float, double and string equals to Perl’s scalar in concept and the numbers and strings are exchangeable. Scalar variable is a Perl variable that is used to store scalar data. It uses a dollar sign $ and followed by one or more aphanumeric characters or underscores. It is case sensitive.

101. How To Start Perl In Interactive Mode?

Ans:

  • perl -e -d 1 PerlConsole.

102. What Package You Use To Create A Windows Services?

Ans:

  • use Win32::OLE.

103. What Does This Symbol Mean ‘->’?

Ans:

In Perl it is an infix dereference operator. for array subscript, or a hash key, or a subroutine, then this must be a reference. can also be used as method invocation.

104. What Is Cpan?

Ans:

CPAN is comprehensive Perl Archive Network. its a repository contains thousands of Perl Modules, source and documentation, and all under GNU/GPL or smilar licence. Some linux distribution provide a till names ‘cpan’; which you can install packages directly from cpan.

105. What Is The Difference Between Exec And System?

Ans:

exec runs the given process, switches to its name and never returns while system forks off the given process, waits for its to complete and then return.

106. What Is The Difference Between For And Foreach?

Ans:

Functionally, there is no difference between them.

107. What Is A Regular Expression?

Ans:

It defines a pattern for a search to match.

108. What Is Stderr() In Perl?

Ans:

Special file handler to standard error in any package.

  • – ls -l | grep ^- | sort -nr

Are you looking training with Right Jobs?

Contact Us

Popular Courses