GeekInterview.com
Series: Subject: Topic:

Perl Interview Questions

Showing Questions 1 - 20 of 64 Questions
First | Prev | | Next | Last Page
Sort by: 
 | 

What is meant by 'chomp'? Where do we require this ?

Asked By: suseel | Asked On: May 19th, 2006

Answered by: sergant on: Apr 27th, 2012

chomp VARIABLE chomp( LIST ) chomp This safer version of "chop" removes any trailing string that corresponds to the current value of $/ (also known as $INPUT_RECORD_SEPARATOR in...

Answered by: sharmasundip on: Aug 18th, 2009

chomp removes all special characters from end of given string

I was asked how to implement the UNIX tail command in perl $ tail.Pl t.Txt 10 (display last 10 lines) I kind of managed with the simple array and they playing around with the $#array etc. But they wanted...

Asked By: vm | Asked On: Jun 14th, 2007

Answered by: sergant on: Apr 27th, 2012

"php #!/usr/bin/perl $fileName = shift; $lines = shift; print "tailing file $fileName for $lines lines... "; open FH, $fileName or die "Could not open $fileName"; while ($...

Answered by: SH on: Mar 29th, 2012

Open file, read and print until number of required lines is reached. Memory is saved by not slurping the entire file into an array. "perl $fileName = shift; $lines = shift; print ...

Soap client

Asked By: OPENVMS | Asked On: Dec 27th, 2011

Hi I want to write a simple soap client in perl. if we pass the interger value as a http request. 1. Take an integer or string as command line arguments. 2. Create a http request. 3. Get the response from http. 4. Store the response in xsd schema. please help me out how to write perl soap client.

What is grep used for in perl?

Asked By: ms_2007 | Asked On: Nov 10th, 2007

Answered by: vasu on: Dec 19th, 2011

Code
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. my @myNames = (Jacob, Michael, Joshua, Matthew, Alexander, Andrew);
  5. my  @grepNames = grep(/^m(.*)$/i, @myNames);
  6. foreach my $grepNames (@grepNames) {
  7.         print"the value is :".$grepNames."
  8. ";
  9. }
  10.  

Answered by: contactparagm on: Dec 3rd, 2010

"grep" is a built function which extract all elements in ARRAY, matched by regex/pattern given as argument for grep and return the resultant elements in an array.perl syntax:  &nbs...

What is the difference between die and exit in perl?

Asked By: Godhuly | Asked On: Jan 12th, 2007

Answered by: felix on: Nov 21st, 2011

There is not same it must be difference . I am sure it must difference but same action perform.but returning a value difference may be like string variable what ever may be

Answered by: wow_suraj on: Jun 17th, 2009

1) die is used to throw an exception (catchable using eval).
exit is used to exit the process.

2) die will set the error code based on $! or $? if the exception is uncaught.
exit will set the error code based on its argument.

3) die outputs a message
exit does not.

Install perl module using cpan

Asked By: Tanu_shree | Asked On: Sep 13th, 2008

How to install perl module using cpan. How to include the module in a program?

Answered by: ankitloud on: Nov 20th, 2011

I think the best option will be : type following command on command prompt

cpan App::cpanminus then you can install any module using its name using following command

cpan Module::Apache

let me know if it doesn't work

Answered by: Navshere on: Aug 19th, 2011

perl Makefile.PL
nmake
nmake test
nmake install

# To check successive installation
perl -e "use Twig"

Create a perl script to store the information in excel

Asked By: Cristine Thine | Asked On: Apr 13th, 2011

Hello,--------------------------------------id name address1 cristine new york 2 murray redmond3 kumar Sunnyvale --------------------------------------this is 'samples.Xlsx' file.'id' string in a1, 'name' in b1, 'address' in c1 column in excel file.Create...

Answered by: elavv on: Aug 10th, 2011

You can construct one hash where the the emp id as key to the hash and rest of the elements as values in the structure of array ref. "perl #! use strict; use Spreadsheet::ParseExce...

Create a perl script

Asked By: Cristine Thine | Asked On: Apr 13th, 2011

Hello,------------------------------------------- id name address 1 cristine new york 2 murray redmond 3 kumar Sunnyvale-------------------------------------------this is 'sample.Xlsx' file. (can't attach the image.)'id' string in a1,...

Answered by: Elavazhagan on: Aug 10th, 2011

Keep the student id as key to a hash and the rest of the elements are the array reference.

How do you you check the return code of a command in perl

Asked By: mpathak | Asked On: Dec 5th, 2007

Suppose you run a program/script in perl:system("./server ....");how will you check the return code?

Answered by: contactparagm on: Dec 3rd, 2010

Perl defines predefined variable $? which gives the return code of last command executed.

Answered by: amitkshirsagar on: Jun 22nd, 2009

$r = system("command .. e.g. search");
print"r is $rn";

Here, if $r is 0, that means command has executed successfully.
Any other value means command has failed.

What is the difference between the function oriented and object oriented approach in the modules (cpan). Mention the merits as well demerits of these two types.

Asked By: rajashekar | Asked On: Oct 25th, 2007

Answered by: shalusanju on: Aug 13th, 2010

In the object-oriented style you create one or more CGI objects and then use object methods to create the various elements of the page. Each CGI object starts out with the list of named parameters tha...

What is -> symbol in perl

Asked By: Rajivcitcse2000 | Asked On: Nov 27th, 2007

Answered by: shalusanju on: Aug 13th, 2010

In object oriented PERL, the arrow -> symbol is used for creating or accessing a particular object of a class. For eg. in Perl/Tk 1. use Tk; my $main_win = MainWindow->new(); Here we u...

Answered by: ajit_saley on: Jul 15th, 2009

$arr= [1, 2,2+1 ,3+1];
print "n arr[1]=|".$arr->[1]."|".$$arr[1]."|";

How to implement stack in perl?

Asked By: ms_2007 | Asked On: Nov 10th, 2007

Answered by: singh_Pushpendra on: Aug 13th, 2010

#! /usr/bin/perl -w$str1="Pushpendra Singh";@str=split("", $str1);@stack_array=();foreach $i (@str){ print "nt Item being pushed is : $i"; push(@stack_a...

Answered by: wow_suraj on: May 2nd, 2008

In perl stacks are easy to be implemented. Stacks which follows LIFO (Last In First Out) data structure can be handled in perl with 'POP' and 'PUSH' keywords. POP Example:my $strT...

When do you not use perl for a project?

Asked By: suseel | Asked On: May 16th, 2006

Answered by: darshancruz on: Jul 9th, 2010

@ joe: isnt this for uses of perl ?

Please can some 1 post a better answer

Answered by: deepthi211985 on: Mar 8th, 2010

The question is for not using perl for a project but the answer is for using perl.

How to substitute a particular string in a file containing millions of records?

Asked By: ms_2007 | Asked On: Nov 10th, 2007

Answered by: ratul2783 on: May 3rd, 2010

perl -p -i -e "s/search_string/replace_string/g" SourceFileThe -p option ensures that $_ is assigned each line of each input file in turn and that the program is executed once for each input line.The ...

Answered by: vinod_rapolu on: Nov 14th, 2008

perl -pi -e "s/search_string/replace_string/g" SourceFile

How to remove a directory which has few files in it? I know about rmdir however it does not remove a dir which has files/dir in it!

Asked By: Chintz | Asked On: Nov 23rd, 2006

Answered by: maulikthaker on: Dec 16th, 2009

$dir = /path/
system("rm -Rf $dir");

Answered by: nitashaa on: Jul 15th, 2008

1. system("rm -rf","directorypath");2. A perl script can be created that'll make use of unlink , opendir,readdir,rmdir functions.#!/usr/bin/perlopendir(FD,"/home/tmp"); ---------> open tmp directory ....

What's the significance of @isa, @export @export_ok %export_tags list & hashes in a perl package? With example?

Asked By: geek_zubi | Asked On: Feb 22nd, 2006

Answered by: terrytlin on: Dec 3rd, 2009

Package NewModule;use Exporter; # an application by ‘use’ operator.# This Exporter package has @ISA array to look for a specific method, this array keeps track of classes it is inheriting....

Answered by: Nitien on: Mar 8th, 2006

@ISA ->  each package has its own @ISA array. this array keep track of classes it is inheriting.

ex:

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.

Print this array, sorted in reversed case-insensitive order...

Asked By: Namataraginu | Asked On: Jan 31st, 2008

You have unsorted array of strings, like:my @arr = qw(hello world show must go on);print this array, sorted in reversed case-insensitive order.

Answered by: j0eb0b on: Oct 31st, 2009

my @arr = qw(hello World Show must go on);#close print "@arr nreverse sorted: ", join(", ", reverse sort map {lc $_} @arr), "n"; #closer print "@arr nreverse sorted:...

Answered by: ajit_saley on: Jul 15th, 2009

@arr = qw(ajit satish AJIt amartya maku);

 

foreach my $ele (@arr)

{

        push (@new_arr, lc($ele));

}

print "n new arr= @new_arr";

@rev_arr =reverse sort(@new_arr);

Rename datastage jobs through perl

Asked By: s4sweety | Asked On: Jul 18th, 2008

Please provide me perl scriptwhich reads the data from xcel sheet and renames the dsx file.Process followed to rename is:make a list of old and new file names in xcel sheet.Compare the old file name in the xcel sheet with dsx name.If both are equal then assign the new name to the dsx which is mentioned...

Answered by: gansi on: Sep 30th, 2009

use Win32::OLE;use Win32::OLE::Enum;use Win32::OLE qw(in with);use Win32::OLE::Const 'Microsoft Excel';use Win32::OLE::Variant;use Spreadsheet::ParseExcel;use Spreadsheet::WriteExcel;use Sprea...

How to find type of variable?

Asked By: prabhasgupte | Asked On: Feb 12th, 2008

How to find out whether reference is pointing to a scalAR, array or hash?

Answered by: santhosh_89 on: Sep 19th, 2009

You can use ref function.

Answered by: wow_suraj on: May 2nd, 2008

With 'ref' keyword we can find the data type of the variable.

What does this symbol mean '->'

Asked By: suseel | Asked On: May 19th, 2006

Answered by: sharmasundip on: Aug 18th, 2009

It is a infix dereference operator like in C++.

Answered by: prabhath_01 on: May 31st, 2008

Uses of  "->" Operator:###################1) Reference the method of a module.use CGI;my $cgi = new CGI ();$cgi->header();2) In Perl it is an infix dereference operator. $arr = [ ...

First | Prev | | Next | Last Page

 

 

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Career Counselling

 Have Career Question?

 Ask Chandra

 Ask Only Career questions.

Follow us:
 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, click "Subscribe".