Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: regular expression

by sundialsvc4 (Abbot)
on Mar 16, 2012 at 19:30 UTC ( [id://960051]=note: print w/replies, xml ) Need Help??


in reply to regular expression

Also, as a matter of course, if you know that this is any kind of standard file-format, check for any CPAN modules (or Regexp::Common entries) that might already have a more thorough and complete parsing solution than you might, or might otherwise have to, cobble up on your own.

“Failing that... simplify.”   If the string is complicated but consists of obvious “pieces,” try an algorithm that first, say, splits the string into pieces, then deal further with the particular piece(s) that you need.   “Cleverness,” otherwise known as “Perl golf,” is both difficult to troubleshoot the first time, and nearly impossible to maintain forevermore.   It looks like chicken-scratches ... it is chicken-scratches ...

One last thought is:   spend a few additional CPU nanoseconds to check the pieces for whatever you can assert to be true, and die if anything is inconsistent.   (Split didn’t find exactly, say, 5 pieces?   DIE!   And so on.)   When dealing with a messy file-parsing situation and a very big file, the only actor on this stage who is in a position to verify that this is not Garbage-In, is the computer program itself.   If you put those kinds of tests in, it lets you say, “the program ran to completion without error, therefore, it is now very-likely that the file (and the program) did not contain any of these errors and that the results obtained are therefore much more likely to be correct and reliable.”

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://960051]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-19 15:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found