CGI Perl Interview Questions
Questions Answers Views Company eMail

Why do you use only Perl when there a lot of more languages available in market like C, Java?

1 3408

Try pattern matching for the following: 1) 10.111.23.11 2) /root/abc/cde/fgg/ac.xml --> Get file name without extention. 3) /root/abc/ac.xml/fgg/ac.xml --> Get file name without extention. 4) What does "DIE" meant in PERL? 5) chomp 6) "This is saturday" --> Print the weekday number. 7) 11-2-2009 --> Print the name of the month. 8) Reverse the string without using func in C.

2 6834

Write a script to reverse a string without using Perl's built in function

Nokia,

8 26937

how to find a substring in a string without using substr built in functions, and print the substring found

Nokia,

3 13698

sort a word "system" in perl/shell without using built in functions output should be emssty

emc2,

2 5803

How to sort dates in Perl ?

1 5051

Packing and Unpacking. Hi, I want to get output as 0x23400000345.... in the below example How to get? i tried out, but unable to get the answer $r=0x234; $t=0x345; $y=pack('L L',$t,$r); $x1=unpack('L!',pack('P',$y)); printf("\nThe value is $x1"); I didn't get constant output

1 3121

while (my ($key, $value) = each(%ENV)) { print "$key - $value\n"; } What does the above sample code produce? What function do you use for reading a list of files within a directory? my %hash = ( 'hi' => {'hello' => 'all'}, 'bye' => {'later' => 'gone'} ); print $hash{'hi'}; What is printed when the above code is executed? sub new { my $pkg = shift; my $test = {'name' => shift;}; ???? return $test; } Which one of the following replaces "????" in the above code in order to cause the function new to return an object of type "Test"? while () { ???? print "$_\n"; } Which one of the following statements causes the above code to strip all whitespace from the end of all lines of input and to print the resulting lines to standard output while (my ($key,$value) = each(%hash)) { print "$key - $value\n"; delete $hash{$key}; } open(FILE,"; } close(FILE); my $foo = 21; $foo <<= 5; $foo >>= 4; print $foo; @arr = (1,2,3); {local $" = "\n"; print "@arr\n"; } my $line = "Hello World"; substr($line,5,2) = "abc"; print $line; Why is sprintf rarely used in perl in comparison to similar (or the same) functions in other languages? my $subRef = sub {print shift;}; How is the subroutine above called with one parameter? How can the values of an associative array be placed in sorted order in a new array? What function is often necessary for building data structures to be passed to low-level routines such as ioctl and fcntl? sub foo { if (shift(@_) > 0) { shift; } } print foo(10,5); print foo(-10,5); What does the above sample for (my $i = 1; $i <= 3; $i++) { print 1..$i; print "\n"; } my $data = 5**3 * 12,2+2; print $data; sub foo { my $value = shift; if ($value) { print 1; shift; } else { return shift(@_) + 3; } } print foo(10,20); What is printed as the result of executing the above code? $var = 20; sub s1 { print "$var "; } sub s2 { local $var = 10; s1;} sub s3 { my $var = 30; s1;} s3; s2; s1; On systems that record file ownership, how may the owner of a file be identified? Which one of the following sets $y to be a copy of $x with every occurrence of foo changed to bar? Which one of the following is an array literal that represents a 4-element array containing the numbers 1, 4, 2, and 6? sub foo {2*shift || 'x';} printf ("%s %s %s", foo(5),foo(0),foo(-5)); What does the above sample code print? Suppose $x contains a number. Which one of the following statements sets $y to be a string containing the octal value of $x?

2 10156

Write an expression or perl script to identify the entered ip address is valid or not?

HCL,

5 12132

Hi, I am a accountant. I am preparing a balance sheet but because of staff shortage and time pressures I cant complete it on time. There is lot of common data with last years which I need not retype and I can manage by editing last year’s balance sheet ? Is their any software on net where I can do this easily??

1752

Why we use CGI?

Wipro,

2104

We all know private variables exist in perl. But do private METHODS exist in perl ? Eg ?

AppLabs,

1997

how to get back up from private character editor which is saved in the format of .udf

1835

There is no strict data types in perl unlike in other high level languages like Java so wouldn't that be a problem if a code in perl is to be a written by a big team of 20+ members ?"

Cisco, Oracle,

1991

How to check the status of airplane mode (enable/disable) in perl for Android mobile?

2604


Post New CGI Perl Questions

Un-Answered Questions { CGI Perl }

Remove the duplicate data from @array=(“perl”,”php”,”perl”,”asp”)

610


How to concatenate strings in perl?

583


How to convert strings into an array in perl?

510


What is qq (double q)operator in perl?

547


How to create a directory in perl?

518






What is posix in perl?

514


Define perl scripting?

567


How to determine strings length in perl?

525


Why is it hard to call this function: sub y { "because" } ?

527


Differentiate between arrays and list in perl.

527


You want to add two arrays together. How would you do that?

474


How to open a directory in perl?

525


Give an example of the -i and 0s option usage.

461


What are the logical operators used for small scale operations? Explain them briefly.

529


Explain the meaning of closure in perl.

518