Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: hash keys and regex

by state-o-dis-array (Hermit)
on Dec 24, 2004 at 15:46 UTC ( #417320=note: print w/ replies, xml ) Need Help??


in reply to Re: hash keys and regex
in thread hash keys and regex

Thank you Aristotle, there is some new material here that I'm going to need to work with to understand how exactly this is working. Your help is much appreciated.


Comment on Re^2: hash keys and regex
Re^3: hash keys and regex
by Aristotle (Chancellor) on Dec 24, 2004 at 16:06 UTC

    No problem. :-) Why not just ask?

    Makeshifts last the longest.

      This is awesome! I need to upgrade my regex knowledge, but I've got most of what is going on at least within my range of comprehension. Is plan part of Test::More, or does Test::More have a depedency to Test::Block? Also, it appears that the %testcase hash is not required, you just used it for illustration - that is to say that only the keys are needed, I wouldn't need to decide ahead of time if the value is expected to be valid? I have some more tinkering to do, I need to look more closely at the $rx assignment. Thanks again.

        Well, first of all, all that's necessary is the @tier array and the code generating the regex. All the rest is plumbing which I dropped in there to make sure that the regex does indeed do what it's supposed to do.

        There's no Test::Block module on my machine. plan() is a function of Test::More which takes the number of tests that will be run — since I use key in scalar context (forced by the + 0), it returns the number of keys in the hash, which is the number of tests I'll be running. The %testcase hash is makes adding tests easier, and of course, if I want to test whether the regex works correctly, then I must decide ahead of time what result it is supposed to produce.

        But again, nothing besides the @tier array and the code generating the regex is necessary. I just added all of the testing bits because that code wasn't easy to get right immediately, so I wanted to make sure it behaves as it is supposed to.

        Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2014-07-25 11:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (170 votes), past polls