- Home
- Interview Questions
- Perl
No. The continueblock is executed only when an iteration of a loop is successfully completed.
Again, there are many ways to do this. A possible solution is to use child1, child2, child3,and so on, instead of leftand right
It depends on the amount of memory in the machine. Normally, it is large enough to only be an issue when you are using recursive subroutines.
It's usually pretty easy to tell. In a lot of places, using a list makes no sense:$result = $number + @array; For example, it makes no sense here to add a list to $number, so the length of the list stored in @arrayis used.
The most common use of string substitution is in the printstatement. Normally, when you print a list you don't want to have the elements of the list running together, because you want to see where one element stops and the next one starts. To print the elements of a string without spaces between them, pass the list to printwithout enclosing it in a string, as follows: print ("Here is my list", @list, "\n");
CPAN stands for Comprehensive Perl Archive Network; it’s a collection of usercontributed modules, scripts, documentation, and utilities for use by anyone programming in Perl. CPAN is available at several sites around the world;
The @INC array defines the directories in which Perl will look for modules and code imported into your scripts using use.
Import a module into your script using use with the name of the module and an optional list of variables or import tags. Importing a module gives you access to the variables and subroutines defined by that module.
An import tag defines a subset of variables and subroutines in the module to be imported into your own script. Import tags are defined by the module developer and documented in the documentation for that module.
Subroutines imported from modules can be called just like regular subroutines,
using the name of the subroutine with parentheses surrounding any arguments.
In object-oriented modules, you must create a new object before you can call subroutines.
With a new object stored in a scalar variable, you’d then call a subroutine
using the $var->sub() syntax, where $var is the name of the variable holding the
object and sub is the name of the subroutine. Subroutines defined inside objects are
called methods.