Perl self-test questions

Dr. Dobb’s Journal in its Linux and open source section is running an article by Emmett Dulaney with 50 Perl questions and answers. The focus is mainly on the knowledge of the language itself with questions like:
- What is the simplest type of data that Perl can work with?
- Which operator can be used to take the bottom item from an array?
- You want to close the directory handle EVAN. Which of the following should you use to accomplish this?
- You want your script to read in a value from the keyboard for a variable named $duo. What do you set $duo equal to in the program to have it read a keyboard value? __________ (Fill in the blank.)
- Your script has just read in a variable from the keyboard and you want to strip that variable of the newline character that came in. What operator should you use to perform this operation?

Answers are available on Dr. Dobb’s Journal site.

This entry was posted in Unix/Linux, Web dev. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

7 Comments on Perl self-test questions

  1. Brajendra
    Posted 6/4/2008 at 3:39 am | Permalink

    Which operator can be used to take the bottom item from an array?
    Ans: -1
    for eg : @Array=(5,6,7,”eight”);
    print “$Array[-1]“;
    # will give last element, also $#

  2. Brajendra
    Posted 6/4/2008 at 3:42 am | Permalink

    You want to close the directory handle EVAN. Which of the following should you use to accomplish this?
    Ans: closedir(EVAN);

  3. Brajendra
    Posted 6/4/2008 at 3:43 am | Permalink

    You want your script to read in a value from the keyboard for a variable named $duo. What do you set $duo equal to in the program to have it read a keyboard value? __________ (Fill in the blank.)
    Ans: $duo=;
    chomp $duo;

  4. Brajendra
    Posted 6/4/2008 at 3:44 am | Permalink

    You want your script to read in a value from the keyboard for a variable named $duo. What do you set $duo equal to in the program to have it read a keyboard value? __________ (Fill in the blank.)
    Ans: $duo=;
    chomp $duo;

  5. Brajendra
    Posted 6/4/2008 at 3:45 am | Permalink

    You want your script to read in a value from the keyboard for a variable named $duo. What do you set $duo equal to in the program to have it read a keyboard value? __________ (Fill in the blank.)
    Ans: STDIN in diamond operator

  6. Brajendra
    Posted 6/4/2008 at 3:47 am | Permalink

    What is the simplest type of data that Perl can work with?

    Ans: scalar

  7. Pramod KB
    Posted 12/24/2008 at 4:18 am | Permalink

    How will you execute a shell process from perl? eg: who >> name.txt

    Ans: system (”who >> name.txt”);

One Trackback

  1. [...] published a list of Perl self-test questions by Emmett Dulaney. Check it out to test your Perl knowledge. Checking out Dulaney’s [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*