What is meant by die in a perl program?
Don’t proceed with the rest of the script of the pervious defined condition is NOT met.
What is the use of require and what does it
require is a call to an external program/condition, that has to be met before the scrcipt/program can continue.
What does this mean ‘$^0′
$^ - Holds the name of the default heading format for the default file handle. Normally, it is equal to the file handle’s name with _TOP appended to it.
What is meant by ‘chomp’?
chomp is used to eliminate the new line character. It can used in many different scenarios.
For ex: excuteScript.pl firstArgument.
$firstArg = $ARGV[0];
chomp $firstArg; –> to get rid of the carrige return.
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 structure
What does this symbol mean ‘->’
In Perl it is an infix dereference operator. The if the rhs is an array subscript, or a hash key, or a subroutine, then the lhs must be a reference, can also be used as method invocation: invocant->method
reference the method of a module.
What are the benefits of having global and local variables?
Global variables can be called upon any where in the script. Local variables are not valid outside the code blocks they are created in.
What is a subroutine?
A subroutine is like a function … called upon to execute a task.
What does the word ‘&my variable’ mean? What does the symbol ‘&’ means? What’s purpose of it?
&myvariable is calling a sub-routine. & is used to identify a sub-routine.
What does $_ means?
Default variable in PERL
What interface used in PERL to connect to database. How do you connect to database in perl
DBI.There is DBI module.use DBI;my $dbh = DBI->connect(’dbi:Oracle:orcl’, ‘username’, ‘password’,)
When do you not use PERL for a project?
There’s a lot of text processing
Web-based applications
Fast/expidient development
Shell scripts grow into libraries
Heavy Data manipulation (auditing, accounting, checking etc… backend processing)
Data extraction
transform loading (database etc.)
System admin etc…
Name an instance you used in CPAN module
CGI, DBI are very common packages used from CPAN.
Difference between for & foreach,exec & system?
There is no difference between for and foreach. exec runs the given process, switches to its name and never returns while system forks off the given process, waits for it to complete and then returns.
What’s the purpose of -w.strict,-T?
-w option enables warning.use strict pragma is used then you should declare variables before there use.
What is the use of “STDERR()”?
How to Connect with SqlServer from perl and how to display database table info?
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 avilabale 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.
What’s the significance of @ISA, @EXPORT @EXPORT_OK %EXPORT_TAGS list & hashes in a perl package?
@ISA -> each package has its own @ISA array. this array keep track of classes it is inheriting.
package child;
@ISA=( parentclass);
@EXPORT this array stores the subroutins to be exported from a module.
@EXPORT_OK this array stores the subroutins to be exported only on request.
What is difference between “Use” and “require”. In which case should “Use” be used and not “Require”?
Use :
1. The method is used only for the modules(only to include .pm type file)
2. The included objects are varified at the time of compilation.
3. No Need to give file extension.
Require:
1. The method is used for both libraries and modules.
2. The included objects are varified at the run time.
3. Need to give file Extension.
What is the difference between “my” and “local” variable scope declarations. ?
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.
What is a static function?
A static function is a function whose scope is limited to the current source file. Scope refers to the visibility of a function or variable. If the function or variable is visible outside of the current source file, it is said tohave global, or external, scope. If the function or variable is not visible outside of the current source file, itis said to have local, or static, scope.
also if a variable is declared to be static, then its value doesn’t change within that function.