Perl Programming Fundamentals
Test your knowledge of Perl programming language basics including file operations, variables, loops, subroutines, string manipulation, and debugging.
Questions
If $string contains abcdabcd , what will the following call return? index ($string, “cd”, 3);
- 6
- 4
- -1
- 2
Which operator can be used to access the first item in an array?
- shift
- start
- right$
- left$
Assume that $var has the value hello . What is the value of the following sting?qq(It’s time to say $var);
- It’s time to say $var
- It’s time to say hello
- Both
- None
Which modifier can be used when matching in Perl to match any character?
- S
- V
- I
- C
Which of the following operators work most like substitution?
- /f
- /g
- s///
- m//
Running your Perl scripts with a d switch will perform which task?
- Invoke the Perl debugger
- Disable the Perl debugger
- Disable breakpoints
- Display a stack trace
Which file test can be done to see if a file is a socket?
- -s
- -l
- -S
- -k
How can you include code from another file in your program?
- With the #include preprocessor command
- Adding the file’s directory to @INC and then passing the filename to require.
- Both A & B
- None
What will the following statement return?
- grep(! /^ !/, @array);
- Every non empty list element
- Every list element that does not start with an exclamation mark.
- Every list element.
What is the default sort order in Perl?
- alphabetic
- numeric
- ASCII
- none of the above
Rather than using print, what is often used in Perl when formatting is important?
- printf
- format
- align
- show
Which of the following will call a subroutine named "mom"?
- &mom
- $mom
- mom$
- %mom%
Which operator can be used to create private variables within a subroutine?
- native
- limited
- my
- regional
Within a loop, which operator jumps to the end of the loop but does not exit the loop?
- next
- last
- redo
- leave
To convert a timestamp into a format more readable by a user, which function should you use?
- bitwise
- localtime
- translate
- transform
What value do variables have before they are first assigned?
- undef
- null
- 0
- nil
Which Perl function is used to change the name of a file?
- nameas
- rename
- name
- now_known_as
Which of the following commands should be used to open a filehandle named KAREN to an existing file named sw?
- open KAREN ">sw";
- open KAREN, ">sw";
- open "sw" KAREN;
- open ">sw", KAREN;
Which command should be used to close the filehandle KAREN?
- close KAREN "sw";
- KAREN close;
- close KAREN;
- close &KAREN
Which function can be used to return such information about a file as its UID, GID, CTIME, etc.?
- file
- stat
- info
- mode