
Beginning Perl Web Development - From Novice To Professional (2006)
.pdf
350 ■I N D E X
storing mail server in environment variable, 119
surviving Slashdot effect, 187 service() method, 141 set_message() function, 37–38 shebang line (#!), 202
shell redirect characters, 74 short-circuited evaluation, 325
Simple Mail Transfer Protocol. See SMTP Simple Object Access Protocol. See SOAP singlevs. double-quoted strings, 288–290 Slashdot web site, 187
SMTP (Simple Mail Transfer Protocol), 118–125
creating SMTP object, 119–120 security with, 133
sending messages in Perl, 122–125 setting hello option, 120
setting subject and other header fields, 123–124
specifying localaddr(), localport(), and port options, 121
timeout value for server, 121
SOAP (Simple Object Access Protocol) about, 137–138
about SOAP::Lite, 139 defined, 137
setting up SOAP objects, 140–142 web sites with SOAP interfaces, 139
SOAP listener, 146–148 SOAP::Lite
about, 139
calling methods, 142–144
calling National Weather Service SOAP service, 149–152
calling SOAP server, 148–149 creating SOAP listener, 146–148 documentation for, 142
error handling, 144–145 importing and debugging, 139–140
printing ISBN search results, 143–144 security for SOAP web services, 152 setting types and names, 145–146 setting up SOAP object in, 140–142 traceable events in, 140
using autodispatch, 144 SOAP::Transport::HTTP module, 148 SOAP-based web services, 137–152 special variables, 313
SQL (Structured Query Language) creating HTML table for output, 67–69 logging queries, 70
outputting statements to HTML, 65–67
:standard group, 6 standards for cookies, 17 state() method, 55
statement handles about, 53–54 defined, 50
using binding parameters in, 63 statements
sanitizing with quote() method, 71 statement blocks and, 284
status codes in HTTP, 92 status line, 91
STDERR filehandle, 73–74, 75 STDIN filehandle, 73–74 STDOUT filehandle, 73–74 stream-based parsing
about, 165, 166 XML::SAX for, 172
string operators, 302–306 strings, 288–291
alternative delimiters for, 291 comparing, 318–319
converting between numbers and, 292–293
creating quotes with q// and qq//, 290–291
singlevs. double-quoted, 288–290 string comparison operators, 305, 318 string value comparisons, 304–306
submitting web forms, 100–101 subrequests, 278
suEXEC feature, 73, 85 SWITCH conditionals, 253 Sybase, 51
syntax
expression modifier, 324–325 if statement, 315
Mason, 269–278
Mason component, 271–272 operation, 308
request line, 91
Template Toolkit, 234, 240–257 while loop, 326
syntax checks, 28
system() function, 84, 85, 86 system interaction, 73–86
based on environment variables, 45–46
with CGI scripts, 26–27 closing filehandles, 76 defined, 73
executing system processes from Perl, 84–85
filehandles for, 73–74 obtaining directory listings, 77 opening filehandles, 74–75 Perl script permissions and, 73 protecting temporary files, 83
security considerations with, 85–86 trapping errors with die(), 75

■I N D E X 351
uploading files with CGI.pm, 77–83 |
updating web sites with ttree program, |
working with system processes, 83–85 |
236–240 |
writing to filehandles, 76 |
using with Perl, 233 |
-X file tests, 76–77 |
working with directives, 246 |
system processes. See also system interaction |
text editors, 283 |
about spawning external processes, 83–84, |
Time::HiRes module, 131 |
86 |
time period abbreviations, 20 |
executing from Perl, 84–85 |
timeouts |
as filehandles, 85 |
setting, 98–99 |
overview, 86 |
setting Net::POP3, 109 |
run quotes for executing, 84–85, 86 |
setting SMTP server, 121 |
using within CGI script, 85 |
tokens, 165 |
■T |
top() method, 115 |
top-level components, 264 |
|
\t escape sequence, 288 |
tpage program |
table() method, 67, 68 |
changing tag styles for, 243–244 |
tags |
using, 235–236 |
HTML tags within CGI module, 11–12 |
tracing in SOAP::Lite, 139–140 |
printing blinking, 269–270 |
Transmission Control Protocol (TCP), 128, |
removing HTML tags from web page, |
132 |
103–104 |
tree parsing, 166, 179–180 |
spaces within comment start, 243 |
troubleshooting database connections, 70 |
Template Toolkit, 243–244 |
troubleshooting tools, 28–31 |
taint (-T) mode, 32–33, 202 |
Carp module, 29–31 |
TCP (Transmission Control Protocol), 128, 132 |
syntax checks, 28 |
Template Toolkit. See also directives |
-w option, 28 |
about, 234–235 |
truth and falsehood |
adding comments in templates, 242–243 |
operator, 298–299 |
building web sites with, 257, 259–261 |
testing conditions, 316 |
chomping, 240, 241–242 |
TRY-CATCH block, 253–254 |
comment processing with spaces in start |
-T option, 32–33 |
tag, 242–243 |
ttree program, 236–240 |
creating web site configuration file with, |
changing tag styles for, 243–244 |
257–259 |
creating run control file for, 237–239 |
defining and setting variables, 244–245 |
options available with, 236–237 |
directives, 246–255 |
options for, 239–240 |
documentation for, 257, 262 |
.ttreerc file, 237–238 |
INTERPOLATE option, 240, 242 |
■U |
mathematical operations on variables, |
|
245–246 |
UDP (User Datagram Protocol), 128 |
plug-ins, 255–257 |
uidl() method, 113–114 |
security issues for, 262 |
unless statements, 324 |
syntax, 234, 240–257 |
unpacking Apache source code, 194 |
tags available in, 243–244 |
until loops, 329–330 |
updating web sites with ttree program, |
upload() function, 78–79 |
236–240 |
uploadInfo() function, 80 |
using as module in Perl programs, 240 |
uploading files |
using tpage program in, 235–236 |
with Apache::Upload module, 225–226 |
virtual methods, 246 |
with CGI.pm, 77–83 |
templates, 233–262. See also directives |
URI::Escape module, 39–43 |
about Template Toolkit, 234–235 |
uri() method, 141, 149 |
comment processing with spaces in start |
uri_escape() function, 40–42 |
tag, 242–243 |
URIs (Universal Resource Identifiers), 39–40 |
defining and setting variables for, 244–245 |
use strict; statement, 33, 201 |
mathematical operations on variables, |
user agent values |
245–246 |
determining browser with, 45–46 |
processing with tpage program, 235–236 |
improper uses of, 97 |

352 ■I N D E X
logging based on, 229
printing from headers_in() output, 219–220
User Datagram Protocol (UDP), 128 user() method, 111
usernames
database security for stored, 70–71 setting up for POP3 servers, 111
■V
values
comparing string, 304–306 viewing variable, 313–315
variables, 306–313 about, 306
autoincrement and autodecrement, 308–310
checking tainted use of, 33
declaring with leading underscore, 245 defined, 285
defining and setting for templates, 244–245
FOREACH directive with loop, 250 interpolating, 313–315 interpolating $, 242
lexical, 310–312
mathematical operations on template, 245–246
modifying, 306–308 names of, 313 special, 313
syntax for operating and assigning at once, 308
testing definitions with if statements, 320 virtual methods for manipulating, 246
verbose output, 28 versions
CGI module, 4–5 RSS, 153, 159
viewing
environment variables in CGI script, 23–24 name_value pairs with headers_in()
method, 218–219 virtual methods, 246
■W
warnings on shebang line, 202 web forms. See forms
web servers
setting timeouts, 98–99
support for HEAD method by, 94
Web Service Definition Language (WSDL), 138
web sites. See also templates
building from template, 257, 259–261 building web page, 278–279 controlling browser redirects, 99
converting to Mason, 233
creating site configuration file with Template Toolkit, 257–259
Mason for, 263–264 mirroring, 102
password and username authentication for, 101–102
removing HTML tags from page, 103–104 sending additional header lines to pages,
99
setting additional parameters for get() function, 98
setting web page timeouts, 98–99 SOAP interfaces used by, 139 updating with ttree program, 236–240
while <STDIN> behavior, 327–328 WHILE directives, 252
while loops about, 326–327 infinite, 329
using while as statement modifier, 332–333
while <STDIN> behavior, 327–328 white space in Perl programs, 285 wildcard hosts (%)
defined, 59
pushing query results into array to find, 59–60
WRAPPER directives, 248 writing
error logs, 227–229 to filehandles, 76
first Perl program, 283–285 RSS, 159–162
WSDL (Web Service Definition Language), 138 -w option, 28
■X
-X file tests, 76–77
XML (eXtensible Markup Language). See also SOAP::Lite; XML::RSS module
creating SAX2 handler package for parsing, 176–177
parsing considerations in, 166 security with parsing, 180 SOAP and, 137
stream-based parsing, 165–166 tree-based parsing, 166, 179–180 XML::SAX for parsing, 172–179 XML::Simple for parsing, 166–168
XML::Grove, 179 XML::LibXML::SAX::Parser, 172 XML::Parser, 179 XML::RSS::Feed module, 163 XML::RSS module
debugging RSS scripts, 158–159, 163 parsing RSS feeds, 155–157, 163

■I N D E X 353
reading RSS with, 154–155 |
security and XML parsing, 180 |
security with, 162 |
tree-based parsing, 179–180 |
versions of RSS, 153, 159 |
XML::Simple, 166–168 |
writing RSS with, 159–162 |
Data::Dumper module for parsing with, |
XML::SAX::PurePerl, 172 |
168–170 |
XML::SAX module, 172–179 |
forcearray option in, 168, 170–171 |
coding main program for parsing, 176 |
KeyAttr option in, 171–172 |
coding parsing routine using, 175–179 |
parsing with, 167–168 |
content event handlers, 173, 174 |
subroutines for, 166 |
creating handler package, 176–177 |
XML::SimpleObject, 179 |
error event handlers, 173, 175 |
XML::TreeBuilder, 179 |
including attributes for parser, 178–179 |
XML::Twig, 179–180 |
listing parsers on system for, 172–173 |
XMLin() subroutine, 166, 167, 168, 169 |
parser methods for, 173 |
XMLout() subroutine, 166 |
running parser, 177 |
XOR (^) operator, 297 |



forums.apress.com
FOR PROFESSIONALS BY PROFESSIONALS™
JOIN THE APRESS FORUMS AND BE PART OF OUR COMMUNITY. You’ll find discussions that cover topics
of interest to IT professionals, programmers, and enthusiasts just like you. If you post a query to one of our
forums, you can expect that some of the best minds in the business—especially Apress authors, who all write
with The Expert’s Voice™—will chime in to help you. Why not aim to become one of our most valuable partic-
ipants (MVPs) and win cool stuff? Here’s a sampling of what you’ll find:
DATABASES
Data drives everything.
Share information, exchange ideas, and discuss any database programming or administration issues.
INTERNET TECHNOLOGIES AND NETWORKING
Try living without plumbing (and eventually IPv6).
Talk about networking topics including protocols, design, administration, wireless, wired, storage, backup, certifications, trends, and new technologies.
JAVA
We’ve come a long way from the old Oak tree.
Hang out and discuss Java in whatever flavor you choose: J2SE, J2EE, J2ME, Jakarta, and so on.
MAC OS X
All about the Zen of OS X.
OS X is both the present and the future for Mac apps. Make suggestions, offer up ideas, or boast about your new hardware.
OPEN SOURCE
Source code is good; understanding (open) source is better.
Discuss open source technologies and related topics such as PHP, MySQL, Linux, Perl, Apache, Python, and more.
PROGRAMMING/BUSINESS
Unfortunately, it is.
Talk about the Apress line of books that cover software methodology, best practices, and how programmers interact with the “suits.”
WEB DEVELOPMENT/DESIGN
Ugly doesn’t cut it anymore, and CGI is absurd.
Help is in sight for your site. Find design solutions for your projects and get ideas for building an interactive Web site.
SECURITY
Lots of bad guys out there—the good guys need help.
Discuss computer and network security issues here. Just don’t let anyone else know the answers!
TECHNOLOGY IN ACTION
Cool things. Fun things.
It’s after hours. It’s time to play. Whether you’re into LEGO® MINDSTORMS™ or turning an old PC into a DVR, this is where technology turns into fun.
WINDOWS
No defenestration here.
Ask questions about all aspects of Windows programming, get help on Microsoft technologies covered in Apress books, or provide feedback on any Apress Windows book.
HOW TO PARTICIPATE:
Go to the Apress Forums site at http://forums.apress.com/.
Click the New User link.