- Brief about data structures in perl.Scalars, Arrays and Hashes
- What are the differences between arrays and lists?
- Lists are constant data while arrays are variables.
- Arrays have a name to identify them, while lists don't.
- Elements of an array can be modified and stored in the same array variable but the same is not possible with lists.
- Stack (push,pop) and queue (unshift,shift) operations are possible only on arrays and not possible on lists.What are the differences between arrays and hashes?
- Arrays have numerals as indices while hashes have keys (strings) as indices.
- Arrays are often ordered list while hashes are unordered list.
- Have you used modules in perl? Can you brief about a module and its functions or sub routines?
- File::Find, 2. File::Copy, 3. XML::Simple, 4. DBI, 5. WWW::Machanize, 6. CAM::PDF, 7. CGI, 8. DBIx::Class, 9. Net::FTP
- Difference between use and require.View StackOverflow Answer
- How to create objects in OO perl?
- Write a perl script to validate an IP address.A partly correct way is given here.
- How to sort a numeric array?View StackOverflow Answer
- What are the differences between grep and map functions?View StackOverflow Answer
- How to sort a hash with key,values pairs as name_of_person,age based on their age?
%hash = #hash map of format name => age ("ganesh" => "26", "kumaresh" => "27", "kannan" => "30", ); foreach $value (sort {$a <=> $b} values(%hash)) {print "$value\n" } - How to remove duplicate entries in an array?
my @arr = (1,2,2,3,4,4,5,5,5,6,6,1,1,1); #array having duplicates my %hash; foreach (@arr) {$hash{$_} = undef; #creating a hash key for each array element. this line helps in removing duplicates since hash keys cannot be duplicated and new duplicate key overwrites the old key. } my @res = keys %hash; print "@res"; #prints array without puplicates - What is the use of @ISA array?@ISA is stand for ‘is a’, that means the array contains parents' package
- Why do we need references?If we need to pass multiple arrays/hashes values into subroutine. In that case we used references.
Monday, December 30, 2013
Capgemini - Perl Interview questions with additional answers
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment