Perl Interview Questions
- 1of 1 vote
Answersguys this is one my interview question , pls help me out.
- Danny March 04, 2016 in United States
This is a large file with 1million lines , without opening the file how to add the phrase end of each line using perl .| Report Duplicate | Flag | PURGE
Perl - 0of 0 votes
Answershow to use perl to write a script to deal with the comments in a C++ file?
- holmespanda June 06, 2014 in United States
let's say a file a.cpp, and it contains several comments. You have to remove the comments.
we know that in C++ there two kinds of comments // and /* */
i was trying to use the regex, but later i was stuck when i found that these comments can appear in a string, say "aaa // bbb", then it will be another situation.
can someone help me with this case?
any ideas will be helpful.| Report Duplicate | Flag | PURGE
Amazon Principal Software Engineer Perl - 2of 2 votes
Answersgive me the code for :
Given a string say "I am a human being" the output should reverse all letters of each word but not the whole string as such.
Eg: O/p should be "I ma a namuh gnieb"
I somewhat wrote the code, but i was asked what if there are extra spaces etc.
(i am able to write the code sitting at my desktop at one short but there front of interviewer i am struggling. Need to build up my confidence)
let me know the best and optimised way of writing this code.
Also i suggest people to aviod using inbuilt functions as much as possible
My Answer is as below in perl
- i_learn April 11, 2014 in India#i want the reverse of the letters of all words in a string #eg Input is "I am a human being" then o/p shud be "I ma a namuh gnieb" $str="I am a human being"; @arr=split(' ',$str); print @arr; for($i=@arr-1;$i>=0;$i--) { $_=@arr[$i]; ####intead of above for loop if we use foreach(@arr) then it will reverse the whole string @word=split('',$_); { foreach $n (@word) { unshift(@final,$n); } } } print "\n @final \n";
| Report Duplicate | Flag | PURGE
Amazon Testing / Quality Assurance Algorithm Android Application / UI Design Arrays Automata Coding Data Structures Dynamic Programming Perl - 0of 2 votes
AnswersGiven an array say [0,1,2,3,5,6,7,11,12,14,20]
- i_learn April 11, 2014 in India
given a number say 5.
Now find the sum of elements which sum to 5
eg:2+3=5, 0+5=5 etc.
I guess the interviewer wanted all possible combinations eg 0+2+3=5, etc| Report Duplicate | Flag | PURGE
Amazon Testing / Quality Assurance Algorithm Android Application / UI Design Arrays Coding Data Structures Dynamic Programming Perl Sorting test Testing - 17of 21 votes
AnswersYou have the file with word at a single line.
- madeinindia March 24, 2014 in neitherland for perl backend
#input sample file
abactor
abaculus
abacus
Abadite
.
.
Zyrenian
#Output
******************************************************************a
*************b
**********************************c
**********************d
*******************************************************************************e
a) you have to count the character and create a histogram in alphabetical order.
b) now you have to produce a histogram with max 80 character in line in reference to max count
c) now same out based histrogram based on the character count| Report Duplicate | Flag | PURGE
Booking.com Software Engineer / Developer Perl - 0of 2 votes
AnswersInput : A Perl program file
- Seeker September 25, 2013 in United States
We need to modify the file to have a max of 80 characters per line and create a new perl file.
Problem is we need to use "/" wherever we split the line and also, the split MUST happen at a place with white space. (ASSUMPTION - No is >75 characters)| Report Duplicate | Flag | PURGE
Google Developer Program Engineer Algorithm Perl Python - -1of 1 vote
AnswersWrite a script to compare two files.
- Abhi February 26, 2013 in India
One is primary file and other is secondary.
I need to check if secondary file contains each line of primary (may be in different order) and should not contain any extra data.
exmaple:
cat primary
abc
lmn
xyz
cat secondary:
cat secondary
xyz
abc
lmn
then in this case compare function should give true.
Note: file contains may be any thing like html or xml code or other.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Perl - 1of 1 vote
AnswersI have 4 files,they are a.abc,b,abc,c.abc and d.abc.
- gunturanilkumar007 February 21, 2013 in INDIA
a.abc file contains
file:b.abc
value:4
file:c.abc
value:6
and c.abc file contains
file:d.abc
value:7
file:e.abc
value:3
so now i want to read a.abc file and get the file name and check that file is exist or not if file is exit read the value and print ...these are all based on file hierarchy.| Report Duplicate | Flag | PURGE
SRMicro Info Systems Testing / Quality Assurance Perl - 1of 1 vote
Answers4)Input a number. Convert the number into words using return functions and regular expressions in Perl. Do not use parse functions.(15 => one five)
- ashwint87 August 29, 2012 in India for dsfgfds| Report Duplicate | Flag | PURGE
Ittiam Systems Software Trainee Perl - 0of 0 votes
Answers3)Input email address. Check if it is valid using return functions and regular expressions in Perl. Do not use parse functions.
- ashwint87 August 29, 2012 in India for dsfgfds| Report Duplicate | Flag | PURGE
Ittiam Systems Software Trainee Perl - 0of 0 votes
Answers2)Input a name. Check if it is valid (has atleast 3 letters and one vowel) using return functions and regular expressions in Perl. Do not use parse functions.
- ashwint87 August 29, 2012 in India for dsfgfds| Report Duplicate | Flag | PURGE
Ittiam Systems Software Trainee Perl - 0of 0 votes
Answers1)Input ip address. Check if it is in the range 172.125.1.0 and 172.125.25.0 using return functions and regular expressions in Perl. Do not use parse functions.
- ashwint87 August 29, 2012 in India for dsfgfds| Report Duplicate | Flag | PURGE
Ittiam Systems Software Trainee Perl - 0of 0 votes
AnswersHow do you make variables public, private, or protected in Perl?
- me August 07, 2011| Report Duplicate | Flag | PURGE
Perl - 0of 0 votes
AnswersDescribe the difference between $_ and @_ .
- me August 07, 2011| Report Duplicate | Flag | PURGE
Perl - 0of 0 votes
Answersuse vs require keyword. How to create module
- Interviewee October 07, 2010| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer in Test Perl - 0of 0 votes
AnswersIn a file containing user address and other info find the one with a particular address location
- Interviewee October 07, 2010| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer in Test Perl - 0of 0 votes
Answersuse vs require keyword. How to create module
- Interviewee October 07, 2010| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer in Test Perl - 0of 0 votes
AnswersIn a file containing user address and other info find the one with a particular address location
- Interviewee October 07, 2010| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer in Test Perl - 0of 0 votes
Answersuse vs require keyword. How to create module
- Interviewee October 07, 2010| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer in Test Perl - 0of 0 votes
AnswersIn a file containing user address and other info find the one with a particular address location
- Interviewee October 07, 2010| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer in Test Perl - 0of 0 votes
AnswersHow will you remove white space from a string?
- Anonymous August 04, 2010| Report Duplicate | Flag | PURGE
NetApp Testing / Quality Assurance Perl - 0of 0 votes
AnswersHow do you lock a file on unix platform (solaris)?
- Dhoni July 21, 2010
My answer was:
open (FILE, 'file-name');
flock FILE, 2;
# Do everthing here
flock FILE, 8;
close(FILE);
But interviewer told me that the solution does not work on unix platform.
After the interview i tried running the code on Solaris machine and it did not lock the file :(| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer Perl - 1of 1 vote
AnswersGiven a Hash -
my %hash = ( ABC => [123,456,789], PQR => 345, XYZ => 567, LMN => { abc => 0, pqr => 1, lmn => 2, xyz => { A => 0, B => 1, c => [ {1 => 'ONE', 2 => 'TWO',}, {ONE => 1, TWO => 2,}, {Number => 'Decimals'}, {Words => 'Alphas'}, 'Sample' ] } }, OPQ => 'WORD' );
Write a generic function to find value of key input by user.
- Roshan May 19, 2010
e.g. In above example if key input by user is 'Words' then value found by search function should be 'Alphas'
Write Search($hashRef,$key) function where, hash could be of any type/level such as -
Hash of Hash of Hash of Hash
Hash of Array of Hash.
etc. etc.| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Perl - 0of 0 votes
AnswersGiven is any kind of hash reference simulate the dumper to print the hash.
- Abhishek May 17, 2010| Report Duplicate | Flag | PURGE
Ebay Software Engineer / Developer Perl - 0of 0 votes
AnswersThere is a log file where each line contains fields separated by spaces. One of the fields is the IP address of the source node. We want to find the list of IP Addresses that have the most log entries. Lets say find the top 10 IP Addresses with most log entries. Give the pseudo code for this?
- NJ October 23, 2009| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Perl - 0of 0 votes
AnswersWhat are the three types of basic variables in Perl?
- Telephonic Screen September 05, 2008
What would you use to see if a file exists?| Report Duplicate | Flag | PURGE
Yahoo Production Engineer Perl