Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
matching numeric rangeby state-o-dis-array (Hermit) |
on Feb 24, 2005 at 21:56 UTC ( [id://434275]=perlquestion: print w/replies, xml ) | Need Help?? |
state-o-dis-array has asked for the wisdom of the Perl Monks concerning the following question:
Greetings all, Well, some help that merlyn supplied in the past encouraged me to use map and some regex magic (magic to me, I'm sure basics to everyone else) to solve a problem, everything worked exactly as I hoped until I tried to match a numeric range - doh! can't regex a numeric range. Here's what I have, I've transformed my data and am working with it in this form: A1:123:C and I need to see if it matches any of an array of data in the form A0-7:123:C where 0-7 is a range. What I would like to know is if there is a way to match the :123:C from each expression, and if so, send the test case and match off to a sub to check for a range match of the A1 to A0-7 portion. I could do I'm looking for something more efficient, though. I have to test about 20-40 cases against 30-40 possible matches, and do this about 400 times, in a somewhat time sensitive environment, so effiency is key. UPDATE: I'm not looking for the sub to determine if some number is in the range, I can do that. I'm wondering if there is a better approach than the code that I've listed? UPDATE PART 2: Well, I finally got as close to what I wanted to do as I think I'm going to get. I had to take care of a little tunnel vision, that I fear a shared with you in the way I presented my problem, but here is what I came up with: This way I still have my $check value, and a possible match in @found, and I can send these to a sub to check if the A4 part is in the range of the A0-7 part of the matching value. Thanks to those who were part of my problem solving process.
Back to
Seekers of Perl Wisdom
|
|