Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

RE: RE: Book Review - Perl and CGI for the World Wide Web

by Ovid (Cardinal)
on Jul 08, 2000 at 22:06 UTC ( [id://21659]=note: print w/replies, xml ) Need Help??


in reply to RE: Book Review - Perl and CGI for the World Wide Web
in thread Perl and CGI for the World Wide Web

Okay, I'm going to sit here and kick myself repeatedly. In reading your response, I remember what I forgot to include in the review: Elizabeth Castro doesn't know Perl.

After reading through her little pamphlet (I can't dignify it with the term "book") I came to the conclusion that she needed to get a book out the door quickly and either took a class on Perl or bought a book on it and started writing. That would explain the generally poor quality of her code and why she spends so much time explaining how to FTP and how to create a Web form. Large portions of this book are spent on non-perl things. She also gets her Perl stuff wrong:

    Perl has three operators that let you look inside incoming data and act accordingly: match, substitute, and split.
Is that so? I guess I'll have to throw away tr///;. What a shame. It's really useful.

Another beef I have is the regex she listed to capture any phone number in the form (xxx) xxx-xxx, with the x's being replaced by digits.

/^((\(\d{3}\))? *\d{3}(-| )\d{4},? *)+$/
This regex really isn't bad, but it has some stumbling blocks for the novice programmer (aside form the fact that a novice won't understand it). The problems:
  • It matches numbers where the dash is replaces with a space. That's not a problem, but it's not what she said she was matching.
  • The (xxx) is optional. See my first gripe.
  • The phone number is captured into $1. Fine and dandy. But did you notice the ,? * at the end? We have an optional comma and potentially many spaces being captured. That's probably not what we want in $1.
  • And what the heck is that '+' doing before the '$'? Are we trying to capture one or more phone numbers? Again, this wasn't explained and could confuse the heck out of newbies.
  • Due to the variable-width font in the book, the spaces in the regex are difficult to see.
These gripes may seem petty, but this is programming. We need to be very specific and not just "fudge" things. Castro should not be giving examples that are "almost" correct.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://21659]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-26 03:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found