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

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to