Wednesday, March 28, 2012

Refreshing some basics of PERL || Some common Interview Questions on PERL?

Since you are expected to know Perl and you have used PERL in your projects, it's a very obvious thing that Interviewer ask you the reason for choosing PERL for doing something in your project. Why not other scripting language?

The very simple answer to this question is that Perl is a very power Interpreter and FREE as well :)
Apart from this PERL is portable, easy and Flexible enough of learn & apply.

Subroutine is reusable set of code in Perl which can be accessed from different parts of the script.

CPAN in Perl - CPAN, the Comprehensive Perl Archive Network, is an archive of over 100,000 modules of software written in Perl, as well as documentation for it.

Defining Object of a Class -

use Class;

my $Object= Class->new();

Reading Command-Line arguments in PERL -

@ARGV is the array which contains all arguments we get from Command-line.

#!/usr/bin/perl
$numArgs = $#ARGV + 1;
print "thanks, you gave me $numArgs command-line arguments. ";
foreach $argnum (0 .. $#ARGV) {
print "$ARGV[$argnum] ";
}

Running a BAT file in Perl -

system("start C:\\Temp\\mybatchfile.bat");

Concatenation in Perl -

$filename = "/tmp/" . $file_name . ".tmp";

$filename = "/tmp/${file_name}.tmp";


Lot of basics around Perl are very well covered at  http://www.perl.com/pub/2000/10/begperl1.html

No comments: