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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 13 ■ PERL WEB SITES WITH MASON 273Figure 13-5. The modified conditional code in action■Tip In practice, I use either or a single % on each line of code when I have just a few lines <strong>to</strong>process. I find it easier <strong>to</strong> type % on each line rather than the more formal and , unlessthere’s another reason for using , an example of which you’ll see later.Four additional types of tags are used rather frequently with Mason. These types include <strong>to</strong> indicate another component call. Consider this akin <strong>to</strong> a function call; argumentscan be carried with the call. Another type is and , which indicate a block ofcode <strong>to</strong> be processed before the main page is processed. The and tags areused for code that should run once at component load time, such as the use pragma <strong>to</strong> importthe DBI in<strong>to</strong> a namespace (use DBI;). A final type of delimiter or markup for Mason is and , which process the arguments being passed in<strong>to</strong> the component.Other types of markup are available with Mason, but the seven tag types described in thissection are the ones you’ll likely encounter right away when getting <strong>to</strong> know Mason. Table 13-2presents a recap of the seven frequently used Mason delimiters.Table 13-2. Frequently Used Mason DelimitersDelimiterPurpose Evaluate statements and interpolate values inline.% Execute single lines of <strong>Perl</strong>, conditionals, and loops.Call another component. ... Process incoming arguments <strong>to</strong> a component. ... Process prior <strong>to</strong> the main page. ... Process once at component initialization. ... Execute multiple lines of <strong>Perl</strong>.

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

Saved successfully!

Ooh no, something went wrong!