Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Constructive criticism of a dictionary / text comparison script

by sauoq (Abbot)
on Aug 29, 2003 at 23:21 UTC ( [id://287856]=note: print w/replies, xml ) Need Help??


in reply to Constructive criticism of a dictionary / text comparison script

All in all, it looks fine. And the fact that it works is a big point in its favor. :-) The one thing that immediately stood out to me was your backwhack happiness in the character class in this line:

$element =~ s/[\s\,\!\?\.\-\_\;\)\(\"\']//g;
There is nothing wrong with writing that as
[\s,!?._;("'-]
instead. (Note that the dash ('-') should be last.) Many regex metachars are just fine inside a character class. You really only need to be careful with '\', ']', '-', and '^'. (I.e. the character class: []^\\-])

Also, on a different line you used a literal space inside the character class. That's fine but sometimes it is easier to read if you use \x20 instead.

-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re: Re: Constructive criticism of a dictionary / text comparison script
by allolex (Curate) on Aug 30, 2003 at 06:06 UTC

    Yes. Definitely backslash-happy. This is something that I have wondered about, but never really remembered to look up or ask. It's much easier to read your way. No fear, I will not go defining character class ranges with the dash. :) And using \x20 instead of a literal space is something that never occurred to me before, but seems like such an obviously good idea, that I'll now probably write a bunch of scripts that totally overuse it. ;)

    --
    Allolex

Log In?
Username:
Password:

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

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

    No recent polls found