Re: Module reuse
From: Gunnar Hjalmarsson (noreply_at_gunnar.cc)
Date: 07/11/04
- Previous message: Charles K. Clarkson: "RE: Is "Thank you" okay? [was: where to put modules?]"
- In reply to: Randy W. Sims: "Module reuse (was: Re: Regex for numbers and text)"
- Next in thread: Jeff 'Japhy' Pinyan: "Re: Regex for numbers and text"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: beginners@perl.org Date: Sun, 11 Jul 2004 22:40:30 +0200
Randy W. Sims wrote:
> Gunnar Hjalmarsson wrote:
>> I for one concentrate on learning - and practicing - the basic
>> regex syntax. That way I get better prepared when I need to write
>> less common regexes.
>
> I understand your argument. It is very important to understand what
> is going on, to understand regexs well enough to construct ones
> like we're discussing now.
Okay.
> However,
Now it comes... ;-)
> I do think taking advantage of modules such as Regexp::Common is
> also essential. The reason are the basically the same reasons we
> practice modular, object-oriented, and other programming
> methodologies: To isolate repeatedly used pieces of code so that
> it's use is consistent, changes & fixes are isolated, etc.
The concept of code reuse. To avoid possible misunderstandings, I do
agree that code reuse is also essential. I'm not arguing against code
reuse in general; reusing code by using modules makes very much sense.
But personally I'm applying a 'threshold' before considering the use
of modules: I prefer to code trivial things myself.
I noticed that you said "however"; in other words you agree that there
is a contradiction between learning the basics and having modules do
the basics for you.
The OP in the thread that triggered this discussion has obviously not
yet learned the basics about regexes. Considering that, what's the
better advice? Is it to
- Point him to a module, or
- Point him in the right direction with the aim to helping him
understand what mistakes he did, and helping him improve his skills
with respect to regexes?
(You can of course do both.)
After all, this is a beginner level list, and I suppose you'd better
learn how to walk before trying to run. :)
> If that's not enough, let me point out that parsing numbers is not
> as straightforward as it might seem. Some of the things you must
> consider are: do you allow decimal? Is the decimal a comma or
> period? Do you allow numbers with no digit before the decimal? Do
> you allow negiative/positive indicators? Do you allow scientific
> notation? What about grouping (eg. 123,456.05)? What is the
> grouping symbol? How many digits in each grouping? etc. There is a
> lot of variation to consider. And it's already been considered by
> someone else in Regexp::Common.
Indeed there are a few variations to consider. And you can't skip
those considerations even if you use Regexp::Common, but you must know
what you are doing in order to pick the right method(s) and use the
right RC syntax. Just like you must know what you are doing in order
to write the regex correctly, if you choose to take that route.
-- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl
- Previous message: Charles K. Clarkson: "RE: Is "Thank you" okay? [was: where to put modules?]"
- In reply to: Randy W. Sims: "Module reuse (was: Re: Regex for numbers and text)"
- Next in thread: Jeff 'Japhy' Pinyan: "Re: Regex for numbers and text"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|