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.
$target_name = $1 if m[( \d{5,6} ) _at: \d{3} : \d{3} ]x;
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
$target_name = $1 if m[( \d+ ) _at: \d+ : \d+ ]x;
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.
|