The idea of this is quite simple. In Locate char in a string I gave an explanation of the principle from which you can loop over a match. All that is left is to explain the match. \d, of course, is a digit. \d{1,3} is short-hand for saying "1-3 digits". By default it matches as much as possible, so that will grab 3 digits at a time. I assume that you would want the final digit or two to be grabbed as well. Putting parens around it causes the matched section to be popped into a variable, $1.while ($expect_data =~ /(\d{1,3})/g) { my $next_chunk = $1; # Validate here }
If this sounds like a bit much, well I just threw a lot at you. Try some examples though and it shouldn't take long to get a sense how it works. What you are looking for is anything on "regular expressions". Any introductory book has material on this, and the standard reference that I have to recommend is Mastering Regular Expressions by Friedl.
As always, /tell me if you have problems figuring out how to use this advice.
In reply to Re: Sorting
by tilly
in thread Parsing a string for sorting
by grasshopper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |