in reply to Re: Why is it matching??
in thread Why is it matching??
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Why is it matching??
by BrowserUk (Patriarch) on Sep 11, 2003 at 22:48 UTC | |
The rebuke wasn't intended to come across as harsh. Sorry that it did. Moving right along. Could you explain a little more of what you mean by ...but I couldn't get your program to work as stated...? I just downloaded the code again and it produced the output I listed, which show that two keys were created. The first with three probes found
And the second with 10:
This is as expected from the sample data you provided on that original post, although I've manually wrapped it to prevent it getting confused by the autowrapper. If you are getting different output when you run my original code, then could you post the output you get please and I'll try to work out what could be different. The way $target name gets updated in the original is like this.
$target_name is set at the top of the outer do..until loop. The code enters the inner while loop, reads the next line, extracts the probe pushes it onto the HoA. It then gets to the last unless defined... line, where it reads another line. So long as it hasn't reached the eof, then it loops back to the top and tests the while condition again. If it matches, the loop repeats, another probe is read and pushed. If it doesn't, then it falls out of the while loop and the until eof DATA condition is tested. If it's not at the eof, then it loops back to the top of the do...until loop and the new $target_name is extracted from the last line it read (which failed to match the while condition) and the cycle repeats. Hopefully, that explains how it works and will allow you to modify it to your needs. Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller If I understand your problem, I can solve it! Of course, the same can be said for you. | [reply] [d/l] [select] |
by bioinformatics (Friar) on Sep 12, 2003 at 17:00 UTC | |
Bioinformatics | [reply] [d/l] |
by BrowserUk (Patriarch) on Sep 12, 2003 at 17:16 UTC | |
Close. You need to note the differences between "s and 's a little more carefully:) I think this does what you want. Sometimes it helps to spread the individual clauses of a statement across seperate lines. It helps you keep track of what is going on. I've also added parens to the join function. They often aren't necessary, but it helps to clarify what bits are arguments to join and which bits (the return from join included) are arguments to print.
HTH. Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller If I understand your problem, I can solve it! Of course, the same can be said for you. | [reply] [d/l] |
by bioinformatics (Friar) on Sep 16, 2003 at 19:18 UTC | |
NOTE: the first half of the file is the 6 digits, while the second half is the 5 digit target name. Is it possible that the program stops partway throught the file since it can't imediately find a matching pattern? I thought that the $1 would cause it to look for the first matching pattern, no matter where it is in the file.... Bioinformatics | [reply] |
by BrowserUk (Patriarch) on Sep 16, 2003 at 20:23 UTC | |
I'm not sure I've fully appreciated all that you've said in this post, it's quite difficult to visualise without real examples of the lines in front of me, but I think that all you need to do is be a little more flexible in what you allow the regex to match.
The \d{5,6} will allow that part of the regex to match a sequence of either 5 or 6 digits followed by _at:. Will this do wnat you need? In general, it's usually good practice to only tighten the regex as far as you need to prevent unwanted matches. You might for instance get away with using
which would allow for ... 1_at: 1:1 to . ... 12345678901234567890: 1234567890:1234567890 And all stations in between. Without being able to see a fully representative sample of your data, its difficult to know just how tight you need to make the regex to avoid false matches, but hopefully this will allow you to experiment to make that determination for yourself? If you find that you are still missing some lines, try adding a prrint statement or two to display the line that was read, and those that were rejected. And post the lines that were falsey rejected along with the regex you are using and it will make it easier for us to help you refine the regex to your needs. Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller If I understand your problem, I can solve it! Of course, the same can be said for you. | [reply] [d/l] [select] |