A few additional observations:
In the foreach loop there is no need for explicit indices, since these are used only to identify array elements. It’s simpler and clearer to loop directly over the elements themselves: for (@outputlist) { This has the additional benefit that you don’t need to use the binding operator (=~) explicitly, because $_ is “understood”:
for (@outputlist) { print ... if /.../; }
Testing that a string matches /^0/ and then testing that it matches a longer pattern beginnning with /^0.../ is fairly pointless here.
The input line:
" 0 258520344 520344 0"
will not match any pattern beginning /^0.../ because there is whitespace before the zero digit. You need something like this:
/ ^ \s* 0 \s+ (\d+) \s+ (\d+) \s+ 0 \s $ /x
Note the quantifiers: * means zero or more, + means one or more. See “Quantifiers” in perlre. (The /x modifier just makes the regex easier to read.)
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: REGexp match query
by Athanasius
in thread REGexp match query
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |