Perl State Machine - Quiz Explanation
The answers you selected are indicated below, along with text that explains the correct answers.
1.
How does the state-machine model improve CGI programs?
Please select the best answer.
A.
It tracks a user through the use of cookies.
B.
It helps a program keep track of its own flow.
C.
It passes information to the Web.
The correct answer is B.
The state-machine model improves CGI programs by helping a program keep track of its own flow. It is a technique for restoring the state of a program when it is called from another iteration of itself. This allows you to build more-complex systems by simply adding states as you go along.
2.
How is state-management data usually passed in Web-based state-machines?
Please select the best answer.
A.
hidden fields
B.
cookies
C.
call by reference
The correct answer is A.
State data is usually passed in hidden fields.
Cookies are more commonly used for long-term data so that users can be identified when they return at another time. Hidden fields are more useful for keeping track of users in a contiguous session.
3.
Why is the state-machine necessary for Web-based programs?
Please select the best answer.
A.
The state-machine sends hidden form elements before terminating
B.
Web programs send only one object before terminating
C.
The state-machine calls the validate routine
The correct answer is B.
The state-machine is necessary for Web-based programs because Web programs send only one object before terminating. HTTP 1.0 was not designed to keep a connection alive beyond one transaction. The state machine makes it possible so know that a user connecting to a later page is the same user who was at a previous page.