Rick Welykochy wrote:

Peter Abbott wrote:

if ( $_ =~ m/^Box(\d) ([A-Z]+(\. | ?)[A-Z]* ?[A-Z]*).*?(\d).*?(\d\d\.\d
\d).*?(\d*\.\d\d)L/) {
        $box, = $1;
        $name = $2;
        $place = $4;
        $time = $5;
        $margin = $6;
        $name =~ s/\.//;
            }

Please write maintainable code that is easy to understand.

I'll put my money where my mouth is ...



  $match = qr/^Box(\d) ([A-Z]+(\. | ?)[A-Z]* ?[A-Z]*). ... etc/;

  if (m/$match/)
  {
      ($box,$name,$place,$time,$margin) = ($1,$2,$4,$5,$6);
      $name =~ s/\.//;
  }



i.e. my rule of matching: grab the $placement variables in the statement,
to be sure, to be sure :)

The qr/.../ creates a pattern match, precompiled. And it can be used
multiple times in your code. Easier to maintain.

It's the one thing missing from python: ease of handling regexs. Yes, yes,
there is the 're' package, but that is an O-O implementation. ot part of
the language.

It is for that reason alone that my GLPs (grungy little programs) are still
whipped up in perl instead of python.


cheers
rickw




--
________________________________________________________________
Rick Welykochy || Praxis Services || Internet Driving Instructor

The best way to accelerate a PC is 9.8 m/s2
     -- anon
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to