go ahead... be a heretic | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
What about something like this:
This is untested, as you did not provide any data test file. A real data file might be useful also to clarify some of my questions below. Note that I did not change the "if $_ ~~ $patterns..." part in the most inner loop because I don't know what you are exactly trying to achieve with the smart match operator, but I would be tempted to rewrite the line as:
I also slightly changed your logic, because it seemed flawed to me: if your current data line matches, say, the first pattern, your program does not test the other patterns, whereas the same line could very well match two or more different patterns and should probably counted for the other patterns. If you really want to stop testing the patterns as soon as you've got one match, then you need to change my most inner loop to this:
or
I would advise to read very carefully each line of my suggested program, it is very very different from yours and you might learn a few things from it if you take the time to try to understand everything. And don't hesitate to ask if there is something you don't understand, my fellow brothers and myself will be happy to explain. In reply to Re: Better way of doing!
by Laurent_R
|
|