Perl Scripting Interview Questions and Answers



Can anyone help on these questions which i couldnt answer in my interview,because iam not sure on perl scripting iam learning the things in perl now.

1.What standard Perl modules have you made use of, and why did you use them instead of the equivalent built-in functions?

2.Write a statement that checks to make sure there are at least two command line arguments and exits with an error if not.

3.How do you find the number of elements in an array?

4.Write a regular expression that would match only the last director of a full path filename (and you don’t know the path ahead of time).  Example: for “/fee/fi/fo/fum.txt” you would match “fo” with your regular expression

5.Write a Perl script to get the machine host name and print it. No system command should be used; this script should work on Windows and Linux OS without any change.
6.Write a Perl script to check a directory exists or not and print proper message. The directory location will be passed as parameter while executing the script.

Please help me out for the above questions.

Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x