10.07.2015 Views

Beginning Web Development With Perl : From Novice to ... - Nabo

Beginning Web Development With Perl : From Novice to ... - Nabo

Beginning Web Development With Perl : From Novice to ... - Nabo

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

270CHAPTER 13 ■ PERL WEB SITES WITH MASONFigure 13-2. The output from the tag exampleAs with any terse example of this nature, it only serves <strong>to</strong> show that your Mason installationis working and not much else. In addition, there are multiple ways <strong>to</strong> create the outputshown in Figure 13-2. I chose one of the more verbose ways <strong>to</strong> do it, since it provides a goodtransition in<strong>to</strong> some of the less verbose methods shown later in this section.In this section, we’ll start off by examining components, and then we’ll move on <strong>to</strong> look atrequest objects, handlers, and subrequests.ComponentsAs mentioned previously, central <strong>to</strong> working with Mason is the component object. The MasonDeveloper’s Manual describes a component as “a mix of <strong>Perl</strong> and HTML” and the “basic buildingblock and computational unit.” A component can be a portion of a page that containsMason sections, or it can be an entire page, or it can be anything in between. Components cancall other components, passing information between them and the current request.The example shown in Listing 13-1 is itself a component. A slightly more complex exampleis shown in Listing 13-2.Listing 13-2. A Slightly More Complex Mason Example% my $time = time;The time is , thanks for visiting.The results of this example appear in Figure 13-3.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!