Developing Web Applications with Apache MySQL memcached and Perl 1 Original Edition Patrick Galbraith - Read the ebook online or download it for the best experience
Developing Web Applications with Apache MySQL memcached and Perl 1 Original Edition Patrick Galbraith - Read the ebook online or download it for the best experience
com
https://ebookname.com/product/developing-web-applications-
with-apache-mysql-memcached-and-perl-1-original-edition-
patrick-galbraith/
OR CLICK HERE
DOWLOAD EBOOK
https://ebookname.com/product/beginning-php-apache-mysql-web-
development-michael-k-glass/
https://ebookname.com/product/sams-teach-yourself-php-mysql-and-
apache-all-in-one-julie-c-meloni/
https://ebookname.com/product/web-graphics-perl-tk-best-of-the-
perl-journal-1st-edition-jon-orwant-ph-d/
https://ebookname.com/product/the-truth-about-chronic-pain-
patients-and-professionals-speak-out-about-our-most-
misunderstood-health-problem-1st-edition-arthur-rosenfeld/
Cool Time A Hands on Plan for Managing Work and
Balancing Time 1st Edition Steve Prentice
https://ebookname.com/product/cool-time-a-hands-on-plan-for-
managing-work-and-balancing-time-1st-edition-steve-prentice/
https://ebookname.com/product/metathesis-in-natural-product-
synthesis-strategies-substrates-and-catalysts-1st-edition-janine-
cossy/
https://ebookname.com/product/14420137-2018th-
edition-%e8%a2%81%e9%9b%8d/
https://ebookname.com/product/the-routledge-companion-to-the-
christian-church-1st-edition-gerard-mannion-and-lewis-s-mudge/
https://ebookname.com/product/toward-a-theology-of-eros-
transfiguring-passion-at-the-limits-of-discipline-1st-edition-
keller/
Statistical modeling for biomedical researchers 1st
Edition William D. Dupont
https://ebookname.com/product/statistical-modeling-for-
biomedical-researchers-1st-edition-william-d-dupont/
Developing Web Applications with Perl,
memcached, MySQL® and Apache
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
Chapter 1: LAMMP, Now with an Extra M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2: MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Chapter 3: Advanced MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Chapter 4: Perl Primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Chapter 5: Object-Oriented Perl. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Chapter 6: MySQL and Perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Chapter 7: Simple Database Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
Chapter 8: memcached . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
Chapter 9: libmemcached . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
Chapter 10: Memcached Functions for MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
Chapter 11: Apache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
Chapter 12: Contact List Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503
Chapter 13: mod_perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
Chapter 14: Using mod_perl Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
Chapter 15: More mod_perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
Chapter 16: Perl and Ajax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
Chapter 17: Search Engine Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
Appendix A: Installing MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 793
Appendix B: Configuring MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 811
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831
Developing Web Applications with Perl,
memcached, MySQL® and Apache
Patrick Galbraith
ISBN: 978-0-470-41464-4
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections
107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or
authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood
Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be
addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201)
748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including
without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or
promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work
is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional
services. If professional assistance is required, the services of a competent professional person should be sought.
Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or
Web site is referred to in this work as a citation and/or a potential source of further information does not mean that
the author or the publisher endorses the information the organization or Web site may provide or recommendations
it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or
disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be
available in electronic books.
To my wonderful wife, Ruth, whom I have known for 27 years and who has stood by me while writing
this book, even when I couldn’t give her the time she deserved. Also, to my dear friend Krishna,
who gave me inspiration every day.
Credits
Acquisitions Editor Vice President and Executive Group
Jenny Watson Publisher
Richard Swadley
Project Editor
Maureen Spears Vice President and Executive Publisher
Barry Pruett
Technical Editor
John Bokma Associate Publisher
Jim Minatel
Production Editor
Rebecca Coleman Project Coordinator, Cover
Lynsey Stanford
Copy Editor
Sara E. Wilson Proofreader
Corina Copp, Word One
Editorial Manager
Mary Beth Wakefield Indexer
Robert Swanson
Production Manager
Tim Tate
About the Author
Patrick Galbraith lives up in the sticks of southwestern New Hampshire near Mt. Monadnock with
his wife, Ruth. Since 1993, he has been using and developing open source software. He has worked on
various open source projects, including MySQL, Federated storage engine, Memcached Functions for
MySQL, Drizzle, and Slashcode, and is the maintainer of DBD::mysql. He has worked at a number of
companies throughout his career, including MySQL AB, Classmates.com, OSDN/Slashdot. He currently
works for Lycos. He is also part owner of a wireless broadband company, Radius North, which provides
Internet service to underserved rural areas of New Hampshire. His web site, which comes by way of a
5.8GHz Alvarion access unit up in a pine tree, is http://patg.net.
One weekend in 1993, I had the chance to go on a getaway to San Diego. Instead, I opted to stay home
and download, onto 26 floppies, Slackware Linux, which I promptly installed onto my Packard Bell 386.
I could never get the built-in video card to work with X, so I ended up buying a separate video card and
had to edit my XConfig file to get it to work. How much more interesting this was to do than editing a
config.sys and an autoexec.bat! From then on, I was hooked. I worked at Siemens Ultrasound Group in
Issaquah, Washington, at the time. An engineer there named Debra, when asked what was a good thing
to learn, said something I’ll never forget: ‘‘Learn Perl.’’ Debra — you were right!
I always wanted to be a C++ graphics programmer. That didn’t happen because of this thing called the
World Wide Web. I remember Ray Jones and Randy Bentson of Celestial Software showing me a program
called Mosaic, which allowed you to view text over the Internet. Images would be launched using XV.
Everywhere I worked, I had to write programs that ran on the Web, which required me to write CGI in
Perl. So much for my goal of being a C++ programmer — but I consider this a great trade for a great
career. (I did eventually get to write C++ for MySQL!)
I would first like to thank my editor, Maureen Spears, who is not only a great editor, but also a friend.
She gave me much-needed encouragement throughout the writing of this book.
A special thanks goes to John Bokma for his meticulous attention to detail and great knowledge of
Perl — particularly with regard to Perl programming style and convention that I didn’t realize had
changed over the last several years. I was somewhat set in my ways!
Thank you to Jenny Watson, who gave me the opportunity to write this book in the first place!
Thanks to Monty Widenius for creating MySQL and for being a mentor as well as a good friend, and
thanks, Monty, for looking over Chapters 1, 2, and 3! Thanks also to Brian Aker for being another great
mentor and friend, as well as being a software-producing machine with a scrolling page full of open
source software projects that he’s created, including Drizzle and libmemcached. Thanks to Sheeri Kritzer
for her encouragement and for listening to me — she finished her book not too long before I finished
mine, so she understood completely what I was going through.
I’d like to thank my friend, Wes Moran, head of design for Sourceforge, for providing the nice, clean,
simple HTML design I used for many of the examples in this book.
Thanks to Eric Day for his excellent input and review of chapters pertaining to Gearman.
A special thanks to Joaquı́n Ruiz of Gear 6, who provided a lot of input on Chapter 1, as well as Jeff
Freund of Clickability and Edwin Desouza and Jimmy Guerrero of Sun, who put me in touch with others
and were great sources of memcached information.
I would like to thank my current colleagues at Lycos, and former colleagues at Grazr and MySQL, as
well as the team members of Drizzle, for their part in my professional development, which gave me the
ability to write this book. Thanks also to anyone I forgot to mention!
Acknowledgments
Finally, I would like to thank the entire Open Source community. My life would not be the same without
open source software.
There’s a verse in an ancient book, the Bhagavad Gita, that aptly describes how people like Monty
Widenius, Linus Torvalds, Larry Wall, Brian Aker and other leaders within the Open Source community
inspire the rest of us:
‘‘Whatever action a great man performs, common men follow. And whatever standards he sets by exemplary acts,
all the world pursues.’’
x
Contents
Foreword xxv
Introduction xxvii
xii
Contents
Perl Data Types 165
Scalars 165
Arrays 167
Hashes 167
File Handles 168
Type Globs 168
Subroutines 168
Variable Usage 168
References 169
Scalar Usage 173
Array Usage and Iteration 174
Working with Hashes 179
Writing to Files 184
STDOUT and STDERR 184
File Handles to Processes 185
Subroutines 186
Variable Scope 189
Packages 192
Perl Modules 193
Writing a Perl Module 194
@ISA array 197
Documenting Your Module 197
Making Your Module Installable 201
Testing 201
Adding a MANIFEST file 204
CPAN 205
Regex One-Liners 206
Storing Regular Expressions in Variables 207
Regex Optimizations 208
Perl 6 Tidbits 208
Summary 210
xiii
Other documents randomly have
different content
C. KEGAN PAUL & CO., 1, Paternoster Square.
*** END OF THE PROJECT GUTENBERG EBOOK GALILEO GALILEI
AND THE ROMAN CURIA ***
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com