[JaxPM] Perl Code - RFC

j proctor jproctor at oit.umass.edu
Fri Dec 8 10:36:22 CST 2000


On the jacksonville-pm-list; Jax.PM'er j proctor <jproctor at oit.umass.edu> wrote -



> Re below code - Current Jax.PM member thoughts would be most appreciated  :)

What kind of comments?  Style?  It's misbehaving and you don't see it?
Looking for logical traps?

I can't possibly look through it in detail until next week.  If that's
soon enough, I don't mind doing it.  One quick thing as I skimmed it...

somewhere near line 39:

>   # Course Numbers
>   if (/^\D{3,4} (\d{4}(\D)?|XXXX)/) {
>      print NFILE "\n\n$_ ";
>      next;
>   }

I'm nearly certain the first CS class I took at UNF was COP3002CS (say hi
to Bob Rinker for me if you ever see him).  I don't see it in their
current course listing, but there are a couple others with more than one
letter after the number.  Without knowing what you've got for input, I'd
probably go with something more like

/^\D{3,4}\s?(?:\d{4}(?:\s?\D*)|XXXX)/

The ?: only work in Perl 5, of course, and the regex will work just fine
without them.  Anyone ever benchmark to see if not setting the backref
variables if you're not going to use them gives enough of a speed boost to
overcome (presumably) the overhead of the (?: ... ) construct?

I'd use \s? in the one above it, too, unless you really do mean exactly
one space (and even then, isn't {1} extraneous?), and \s+ (etc.) in the
one below it.  If you have to "cook" the file to begin with, how certain
is the spacing of trivial things like course numbers?  

Also, can you rule out descriptions like "This 2000 level course ..."?

Briefly, I'm also going to question the wisdom of writing the cooked data
to a separate file, because I didn't actually read far enough to see if
you did anything with it other than reopen it to snarf everything back in
(and sort out what kind of data it is again).

Damn.  Now you've got me thinking about state machines.


j



Jax.PM Moderator's Note:
This message was posted to the Jacksonville Perl Monger's Group listserv.
The group manager can be reached at -- owner-jacksonville-pm-list at pm.org
to whom send all praises, complaints, or comments...




More information about the Jacksonville-pm mailing list