Re: Module reuse

From: Gunnar Hjalmarsson (noreply_at_gunnar.cc)
Date: 07/11/04

  • Next message: Paul Smith: "Re: My first perl script"
    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
    

  • Next message: Paul Smith: "Re: My first perl script"

    Relevant Pages

    • Re: Program inefficiency?
      ... Even regexes can be legible enough when they are well documented, not to mention the fact that is an idiom common to various languages. ... you spent some time interpreting his code. ... It still doesn't solve the problem of one tag having both attributes with spaces (which can be easily fixed with a second regex, but that was out of question:P), and there can be a lot of other problems, but should provide at least some guidance. ...
      (comp.lang.python)
    • Re: [geek] Advanced Siteswap RegEx
      ... > I've recently been playing around with regexes, ... > It did strike me that with lookaheads and backreferences, ... > regex engine itself. ... > As I've mostly been playing with lookaheads and backreferences at work ...
      (rec.juggling)
    • Re: Need Regular Expressions?
      ... I'm perfectly happy with regexes in a production situation, ... It's also worth noting that the .Net framework includes a regex engine ... (whose regexes are a superset of those available in VBScript). ... Likewise the O'Reilly Regular Expression Pocket Reference. ...
      (microsoft.public.access.modulesdaovba)
    • Anti-hacker regex filtering
      ... executed from within the regexes. ... There are four ways of including code within a regex. ... nothing if there is a preceding backslash because if there ... Is there any way of disguising the extended syntax for code ...
      (comp.lang.perl.misc)
    • Re: File handle Variable scope issue
      ... > sub openconf { ... It's more than a regex. ... capture the matched substring into a capture buffer, ... Gunnar Hjalmarsson ...
      (comp.lang.perl.misc)