Perl Interview Questions

what is it meants by ‘$_’?

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

Difference between ‘my’ and ‘local’ variable scope declarations

Both of them are used to declare local variables. The variables declared with 'my' can live only within the block and cannot gets its visibility inherited [...]

what is meant by a ‘pack’ in perl?

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 [...]

How to substitute a particular string in a file containing million of record?

perl -p -ibak -e 's/search_str/replace_str/g' [...]

how do you check the return code of system call?

System calls "traditionally" returns 9 when successful and 1 when it fails. system (cmd) or die "Error in [...]

What is ‘->’ in Perl?

It is a symbolic link to link one file name to a new name. so lets say we do it like file1-> file2, if we read file1, we end up reading [...]

Difference between ‘chomp’ and ‘chop’?

CHOP 'chop' function only removes the last character completely 'from the scalar, where as 'chomp' function only removes the last character if it is a [...]

Diffrence between ‘use’ and ‘require’ function?

Use: 1. the method is used only for modules (only to include .pm type file) 2. the included object are verified at the time of compilation. 3. No Need to give [...]

How do you know the reference of a variable whether it is a reference,scaller, hash or array?

Answer : There is a 'ref' function .Perl provides the ref() function so that you can check the reference type before dereferencing a referenceThe ref() [...]

What is stack concepts In Perl ?

One of the most basic uses for an array is as stack push | pop ==> LIFO shift | unshift ==> [...]